Properties

$conjunction

$conjunction : string

Type

string

$fields

$fields : array

Type

array

$distinct

$distinct : boolean

Type

boolean

$tests

$tests : array

Type

array

$relationships

$relationships : array

Type

array

$limit

$limit : integer

Type

integer

$limitOffset

$limitOffset : integer

Type

integer

$sortby

$sortby : 

Type

$_sortby

$_sortby : array

Type

array

$_aliasCount

$_aliasCount : integer

Type

integer

$_aliases

$_aliases : array

Type

array

Methods

create()

create(mixed  $query, \Horde_Rdo_Mapper  $mapper = null) : \Horde_Rdo_Query

Turn any of the acceptable query shorthands into a full Horde_Rdo_Query object. If you pass an existing Horde_Rdo_Query object in, it will be cloned before it's returned so that it can be safely modified.

Parameters

mixed $query

The query to convert to an object.

\Horde_Rdo_Mapper $mapper

The Mapper object governing this query.

Returns

\Horde_Rdo_Query

The full Horde_Rdo_Query object.

__construct()

__construct(\Horde_Rdo_Mapper  $mapper = null) 

Constructor.

Parameters

\Horde_Rdo_Mapper $mapper

Rdo mapper base class

setMapper()

setMapper(\Horde_Rdo_Mapper  $mapper) : \Horde_Rdo_Query

Parameters

\Horde_Rdo_Mapper $mapper

Rdo mapper base class

Returns

\Horde_Rdo_Query

Return the query object for fluent chaining.

distinct()

distinct(boolean  $distinct) : \Horde_Rdo_Query

Makes the query return only distinct (different) values.

Parameters

boolean $distinct

Whether to enable a distinct query.

Returns

\Horde_Rdo_Query

Returns self for fluent method chaining.

setFields()

setFields(array  $fields, string  $fieldPrefix = null) : \Horde_Rdo_Query

Sets the fields to return with the query.

Parameters

array $fields

The fields to load with this query.

string $fieldPrefix

Prefix all field names with this string.

Returns

\Horde_Rdo_Query

Returns self for fluent method chaining.

addFields()

addFields(array  $fields, string  $fieldPrefix = null) : \Horde_Rdo_Query

Adds fields to return with the query.

Parameters

array $fields

Additional fields to load with this query.

string $fieldPrefix

Prefix all field names with this string.

Returns

\Horde_Rdo_Query

Returns self for fluent method chaining.

combineWith()

combineWith(string  $conjunction) 

Parameters

string $conjunction

SQL conjunction such as "AND", "OR".

addTest()

addTest(  $field,   $test,   $value) 

Parameters

$field
$test
$value

addRelationship()

addRelationship(string  $relationship, array  $args) : \Horde_Rdo_Query

Adds a relationship type to a query.

Parameters

string $relationship

The name of the relationship as defined in the mapper.

array $args

The parameter array as defined in the mapper:

  • mapper: The mapper object of the result class.
  • table: Optional name of the table to use.
  • tableAlias: Optional alias name for the base table.
  • join_type: Optional explicitly control the type of join.
  • type: The type of relation, any of the constants in Horde_Rdo.

Returns

\Horde_Rdo_Query

This object.

sortBy()

sortBy(string  $sort) 

Add a sorting rule.

Parameters

string $sort

SQL sort fragment, such as 'updated DESC'

clearSort()

clearSort() 

limit()

limit(integer  $limit, integer  $offset = null) 

Restrict the query to a subset of the results.

Parameters

integer $limit

Number of items to fetch.

integer $offset

Offset to start fetching at.

__get()

__get(string  $key) 

Accessor for any fields that we want some logic around.

Parameters

string $key

getQuery()

getQuery() : array

Query generator.

Returns

array —

A two-element array of the SQL query and an array of bind parameters.

_select()

_select(  $sql,   $bindParams) 

Parameters

$sql
$bindParams

_from()

_from(  $sql,   $bindParams) 

Parameters

$sql
$bindParams

_join()

_join(  $sql,   $bindParams) 

Parameters

$sql
$bindParams

_where()

_where(  $sql,   $bindParams) 

Parameters

$sql
$bindParams

_orderBy()

_orderBy(  $sql,   $bindParams) 

Parameters

$sql
$bindParams

_limit()

_limit(  $sql,   $bindParams) 

Parameters

$sql
$bindParams

_prefix()

_prefix(  $fieldName,   $key,   $prefix) 

Callback for array_walk to prefix all elements of an array with a given prefix.

Parameters

$fieldName
$key
$prefix

_alias()

_alias(  $tableName) 

Get a unique table alias

Parameters

$tableName

_fillJoinPlaceholders()

_fillJoinPlaceholders(\Horde_Rdo_Mapper  $m1, \Horde_Rdo_Mapper  $m2, array  $query) : array

Take a query array and replace @field@ placeholders with values that will match in the load query.

Parameters

\Horde_Rdo_Mapper $m1

Left-hand mapper

\Horde_Rdo_Mapper $m2

Right-hand mapper

array $query

The query to process placeholders on.

Returns

array —

The query with placeholders filled in.