Class Query
The class offers many features to compose model queries. Most query related
methods of the ICanBoogie\ActiveRecord\Model
class create a ICanBoogie\ActiveRecord\Query
object that is returned for
further specification, such as filters or limits.
- ICanBoogie\ActiveRecord\Query implements IteratorAggregate uses ICanBoogie\PrototypeTrait (not available)
Methods summary
protected
get_conditions( void )
: array
Return the conditions collected from ICanBoogie\ActiveRecord\Query::where()
, and(), filter_by_*
,
and scopes.
protected
get_args( void )
: array
Returns the arguments to the query, which include joints arguments, conditions arguments, and having arguments.
protected
render_main( void )
: string
Render the main body of the query, without the SELECT
and FROM
clauses.
protected
render_offset_and_limit( integer $offset
, integer $limit
)
: string
Render the LIMIT
and OFFSET
clauses.
public
join( string|ICanBoogie\ActiveRecord\Query
$expression
, array $options
= [] )
: ICanBoogie\ActiveRecord\Query
Add a JOIN
clause.
public
where( mixed $conditions
, mixed $conditions_args
= null, mixed $_
= null )
: ICanBoogie\ActiveRecord\Query
Add conditions to the SQL statement.
public
order( string $order_or_field_name
, array $field_values
= null )
: ICanBoogie\ActiveRecord\Query
Defines the ORDER
clause.
public
having( mixed $conditions
, mixed $conditions_args
= null )
: ICanBoogie\ActiveRecord\Query
Defines the HAVING
clause.
public
limit( integer $limit
)
: ICanBoogie\ActiveRecord\Query
Apply the limit and/or offset to the SQL fired.
protected
get_all( void )
: array
Getter for the ICanBoogie\ActiveRecord\Query::all()
magic property.
protected
get_one( void )
: mixed
Getter for the ICanBoogie\ActiveRecord\Query::one()
magic property.
protected
get_pairs( void )
: array
Execute que query and return an array of key/value pairs, where the key is the value of the first column and the value of the key the value of the second column.
protected
get_exists( void )
: boolean|array
Getter for the ICanBoogie\ActiveRecord\Query::exists()
magic property.
protected
get_count( void )
: integer
Getter for the ICanBoogie\ActiveRecord\Query::count()
magic property.
Magic methods summary
public
and( $conditions
, $conditions_args
= null, $_
= null) Alias to {@link where( )
: ICanBoogie\ActiveRecord\Query
}.
Constants summary
Properties summary
protected
$conditions
: array
The conditions collected from ICanBoogie\ActiveRecord\Query::where()
, and(), filter_by_*
, and scopes.
[]
Magic properties
public read-only
$exists
: boolean|array
true
if a record matching the query exists, false
otherwise. If there is multiple records, the property is an array of booleans.
public read-only
$conditions
: array
The conditions collected from ICanBoogie\ActiveRecord\Query::where()
, and(), filter_by_*
, and scopes.