ORM query object.
 Methods
Does the work for having() and or_having()
_having(array $condition, string $type) : \Orm\Query
| fluent | 
This method is part of a fluent interface and will return the same instance | 
Parameters
$condition
array
$type
string
Exceptions
Returns
  
 
Load the ORM config file
_init() 
 
Add a table to join, consider this a protect method only for Orm package usage
_join(array $join) : \Orm\Query
| fluent | 
This method is part of a fluent interface and will return the same instance | 
Parameters
$join
array
Returns
  
 
Parses an array of where conditions into the query
_parse_where_array(array $val, string $base, bool $or) 
Parameters
$val
array
$base
string
$or
bool
  
 
Does the work for where() and or_where()
_where(array $condition, string $type) : \Orm\Query
| fluent | 
This method is part of a fluent interface and will return the same instance | 
Parameters
$condition
array
$type
string
Exceptions
Returns
  
 
Close a nested and_where condition
and_having_close() : \Orm\Query
| fluent | 
This method is part of a fluent interface and will return the same instance | 
Returns
  
 
Open a nested and_having condition
and_having_open() : \Orm\Query
| fluent | 
This method is part of a fluent interface and will return the same instance | 
Returns
  
 
Close a nested and_where condition
and_where_close() : \Orm\Query
| fluent | 
This method is part of a fluent interface and will return the same instance | 
Returns
  
 
Open a nested and_where condition
and_where_open() : \Orm\Query
| fluent | 
This method is part of a fluent interface and will return the same instance | 
Returns
  
 
Build a select, delete or update query
build_query(\Fuel\Core\Database_Query_Builder_Where $query, array $columns, string $type) : array
Parameters
$type
stringType of query to build (count/select/update/delete/insert)
 
Exceptions
\FuelException | 
Models cannot be related between different database connections | 
\UnexpectedValueException | 
Trying to get the relation of an unloaded relation | 
Returns
arraywith keys query and relations
  
 
Enables or disables the default state of the object cache
caching(bool $cache) : \Orm\Query
Parameters
$cache
boolWhether or not to use the object cache by default
 
Returns
  
 
Sets the name of the connection to use for this query.
connection(string $name) 
Set to null to use the default DB connection
Parameters
$name
string
  
 
Count the result of a query
count(bool $column, bool $distinct) : mixed
Parameters
$column
boolFalse for random selected column or specific column, only works for main model currently
 
$distinct
boolTrue if DISTINCT has to be aded to the query
 
Returns
mixednumber of rows OR false
  
 
Run DELETE with the current values
delete() : bool
Returns
boolsuccess of delete operation
  
 
Create a new instance of the Query class.
forge(string $model, mixed $connection, array $options) : \Orm\Query
Parameters
$model
stringname of the model this instance has to operate on
 
$connection
mixedDB connection to use to run the query
 
$options
arrayany options to pass on to the query
 
Returns
  
 
Enables or disables the object cache for this query
from_cache(bool $cache) : \Orm\Query
Parameters
$cache
boolWhether or not to use the object cache on this query
 
Returns
  
 
Build the query and return hydrated results
get() : array
 
Build the query and return single object hydrated
get_one() : \Orm\Model
 
Get the Query as it's been build up to this point and return it as an object
get_query() : \Orm\Database_Query
Returns
\Orm\Database_Query
  
 
Creates a "GROUP BY .
group_by() : \Orm\Query
.." filter.
| fluent | 
This method is part of a fluent interface and will return the same instance | 
Returns
  
 
Set having condition
having() : \Orm\Query
| fluent | 
This method is part of a fluent interface and will return the same instance | 
Returns
  
 
Alias to and_having_close()
having_close() : \Orm\Query
| fluent | 
This method is part of a fluent interface and will return the same instance | 
Returns
  
 
Alias to and_having_open()
having_open() : \Orm\Query
| fluent | 
This method is part of a fluent interface and will return the same instance | 
Returns
  
 
Hydrate model instances with retrieved data
hydrate(array $row, array $models, \stdClass $result, string $model, array $select, array $primary_key) : \Orm\Model
Parameters
$row
array&$row Row from the database
 
$models
arrayRelations to be expected
 
$result
\stdClassAn object containing current result array
 
$model
stringOptionally. Model classname to hydrate
 
$select
arrayOptionally. Columns to use
 
$primary_key
arrayOptionally. Primary key(s) for this model
 
Returns
  
 
Run INSERT with the current values
insert() : bool | int
Returns
boolintLast inserted ID (if present) or false on failure
  
 
Set the limit
limit(int $limit) : \Orm\Query
| fluent | 
This method is part of a fluent interface and will return the same instance | 
Parameters
$limit
int
Returns
  
 
Get the maximum of a column for the current query
max(string $column) : bool | int
Parameters
Returns
boolintmaximum value OR false
  
 
Get the minimum of a column for the current query
min(string $column) : bool | int
Parameters
$column
stringColumn which min value you want to get
 
Returns
boolintminimum value OR false
  
 
Set the offset
offset(int $offset) : \Orm\Query
| fluent | 
This method is part of a fluent interface and will return the same instance | 
Parameters
$offset
int
Returns
  
 
Set or_having condition
or_having() : \Orm\Query
| fluent | 
This method is part of a fluent interface and will return the same instance | 
Returns
  
 
Close a nested or_where condition
or_having_close() : \Orm\Query
| fluent | 
This method is part of a fluent interface and will return the same instance | 
Returns
  
 
Open a nested or_having condition
or_having_open() : \Orm\Query
| fluent | 
This method is part of a fluent interface and will return the same instance | 
Returns
  
 
Set or_where condition
or_where() : \Orm\Query
| fluent | 
This method is part of a fluent interface and will return the same instance | 
Returns
  
 
Close a nested or_where condition
or_where_close() : \Orm\Query
| fluent | 
This method is part of a fluent interface and will return the same instance | 
Returns
  
 
Open a nested or_where condition
or_where_open() : \Orm\Query
| fluent | 
This method is part of a fluent interface and will return the same instance | 
Returns
  
 
Set the order_by
order_by(string | array $property, string $direction) : \Orm\Query
| fluent | 
This method is part of a fluent interface and will return the same instance | 
Parameters
$property
stringarray
$direction
string
Returns
  
 
Set the limit of rows requested
rows_limit(int $limit) : \Orm\Query
| fluent | 
This method is part of a fluent interface and will return the same instance | 
Parameters
$limit
int
Returns
  
 
Set the offset of rows requested
rows_offset(int $offset) : \Orm\Query
| fluent | 
This method is part of a fluent interface and will return the same instance | 
Parameters
$offset
int
Returns
  
 
Select which properties are included, each as its own param.
select(bool $add_pks) : void | array
Or don't give input to retrieve
the current selection.
Parameters
$add_pks
boolWhether or not to add the Primary Keys to the list of selected columns
 
Exceptions
\FuelException | 
No properties found in model | 
Returns
voidarray
  
 
Set any properties for insert or update
set(string | array $property, mixed $value) : \Orm\Query
| fluent | 
This method is part of a fluent interface and will return the same instance | 
Parameters
$property
stringarray
Returns
  
 
Run UPDATE with the current values
update() : bool
Returns
boolsuccess of update operation
  
 
Determines whether a subquery is needed, is the case if there was a limit/offset on a join
use_subquery() : bool
 
Set a view to use instead of the table
use_view(string $view) : \Orm\Query
Parameters
$view
stringName of view which you want to use
 
Exceptions
Returns
  
 
Set where condition
where() : \Orm\Query
| fluent | 
This method is part of a fluent interface and will return the same instance | 
Returns
  
 
Alias to and_where_close()
where_close() : \Orm\Query
| fluent | 
This method is part of a fluent interface and will return the same instance | 
Returns
  
 
Alias to and_where_open()
where_open() : \Orm\Query
| fluent | 
This method is part of a fluent interface and will return the same instance | 
Returns
  
 
Create a new instance of the Query class.
__construct(string $model, mixed $connection, array $options, mixed $table_alias) 
Parameters
$model
stringName of the model this instance has to operate on
 
$connection
mixedDB connection to use to run the query
 
$options
arrayAny options to pass on to the query
 
$table_alias
mixedOptionally, the alias to use for the models table
 
  
 
/* normalize the select fields passed
_normalize(array $fields, int $i) 
Parameters
$fields
arraylist of columns to select
 
$i
intcounter of the number of selected columnss
 
  
 
Returns target table (or view, if specified).
_table() 
 
Allows subclasses to make changes to the join information before it is used
modify_join_result($join_result, $name) 
Parameters
$join_result
$name
  
 
 Properties
 
<p>table alias</p>
$alias : string
 
 
<p>switch to globally enable/disable object caching</p>
$caching : bool
 
 
<p>connection name to use</p>
$connection : null | string
 
 
<p>whether or not to retrieve a cached object</p>
$from_cache : bool
 
 
<p>group by clauses</p>
$group_by : array
 
 
<p>having clauses</p>
$having : array
 
 
<p>tables to join without returning any info</p>
$joins : array
 
 
<p>max number of returned base model instances</p>
$limit : int
 
 
<p>classname of the model</p>
$model : string
 
 
<p>offset of base model table</p>
$offset : int
 
 
<p>order by clauses</p>
$order_by : array
 
 
<p>relations to join on</p>
$relations : array
 
 
<p>max number of requested rows</p>
$rows_limit : int
 
 
<p>offset of requested rows</p>
$rows_offset : int
 
 
<p>fields to select</p>
$select : array
 
 
<p>select filters</p>
$select_filter : array
 
 
<p>values for insert or update</p>
$values : array
 
 
<p>database view to use with keys 'view' and 'columns'</p>
$view : array
 
 
<p>where conditions</p>
$where : array
 
 
<p>connection name to use for writes</p>
$write_connection : null | string