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

\FuelException

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

\FuelException

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

$query

\Fuel\Core\Database_Query_Builder_Where

DB where() query object

$columns

array

Optionally

$type

string

Type 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

bool

Whether 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

bool

False for random selected column or specific column, only works for main model currently

$distinct

bool

True 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

string

name of the model this instance has to operate on

$connection

mixed

DB connection to use to run the query

$options

array

any options to pass on to the query

Returns

\Orm\Querynewly created instance

Enables or disables the object cache for this query

from_cache(bool $cache) : \Orm\Query

Parameters

$cache

bool

Whether or not to use the object cache on this query

Returns

Build the query and return hydrated results

get() : array

Returns

array

Build the query and return single object hydrated

get_one() : \Orm\Model

Returns

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

array

Relations to be expected

$result

\stdClass

An object containing current result array

$model

string

Optionally. Model classname to hydrate

$select

array

Optionally. Columns to use

$primary_key

array

Optionally. 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

$column

string

Column

Returns

boolintmaximum value OR false

Get the minimum of a column for the current query

min(string $column) : bool | int

Parameters

$column

string

Column 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

bool

Whether 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

$value

mixed

Optionally

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

Returns

bool

Set a view to use instead of the table

use_view(string $view) : \Orm\Query

Parameters

$view

string

Name of view which you want to use

Exceptions

\OutOfBoundsException Cannot use undefined database view, must be defined with Model

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

string

Name of the model this instance has to operate on

$connection

mixed

DB connection to use to run the query

$options

array

Any options to pass on to the query

$table_alias

mixed

Optionally, the alias to use for the models table

/* normalize the select fields passed

_normalize(array $fields, int $i) 

Parameters

$fields

array

list of columns to select

$i

int

counter 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