PHP Class Horde_Rdo_Query, horde

显示文件 Open project: horde/horde Class Usage Examples

Public Properties

Property Type Description
$conjunction string
$distinct boolean
$fields array
$limit integer
$limitOffset integer
$mapper Horde_Rdo_Mapper
$relationships array
$tests array

Protected Properties

Property Type Description
$_aliasCount integer
$_aliases array
$_sortby array

Public Methods

Method Description
__construct ( Horde_Rdo_Mapper $mapper = null ) Constructor.
__get ( string $key ) Accessor for any fields that we want some logic around.
addFields ( array $fields, string $fieldPrefix = null ) : Horde_Rdo_Query Adds fields to return with the query.
addRelationship ( string $relationship, array $args ) : Horde_Rdo_Query Adds a relationship type to a query.
addTest ( $field, $test, $value )
clearSort ( )
combineWith ( string $conjunction )
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.
distinct ( boolean $distinct ) : Horde_Rdo_Query Makes the query return only distinct (different) values.
getQuery ( ) : array Query generator.
limit ( integer $limit, integer $offset = null ) Restrict the query to a subset of the results.
setFields ( array $fields, string $fieldPrefix = null ) : Horde_Rdo_Query Sets the fields to return with the query.
setMapper ( Horde_Rdo_Mapper $mapper ) : Horde_Rdo_Query
sortBy ( string $sort ) Add a sorting rule.

Protected Methods

Method Description
_alias ( $tableName ) Get a unique table alias
_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.
_from ( &$sql, &$bindParams )
_join ( &$sql, &$bindParams )
_limit ( &$sql, &$bindParams )
_orderBy ( &$sql, &$bindParams )
_prefix ( &$fieldName, $key, $prefix ) Callback for array_walk to prefix all elements of an array with a given prefix.
_select ( &$sql, &$bindParams )
_where ( &$sql, &$bindParams )

Method Details

__construct() public method

Constructor.
public __construct ( Horde_Rdo_Mapper $mapper = null )
$mapper Horde_Rdo_Mapper Rdo mapper base class

__get() public method

Accessor for any fields that we want some logic around.
public __get ( string $key )
$key string

_alias() protected method

Get a unique table alias
protected _alias ( $tableName )

_fillJoinPlaceholders() protected method

Take a query array and replace @field@ placeholders with values that will match in the load query.
protected _fillJoinPlaceholders ( Horde_Rdo_Mapper $m1, Horde_Rdo_Mapper $m2, array $query ) : array
$m1 Horde_Rdo_Mapper Left-hand mapper
$m2 Horde_Rdo_Mapper Right-hand mapper
$query array The query to process placeholders on.
return array The query with placeholders filled in.

_from() protected method

protected _from ( &$sql, &$bindParams )

_join() protected method

protected _join ( &$sql, &$bindParams )

_limit() protected method

protected _limit ( &$sql, &$bindParams )

_orderBy() protected method

protected _orderBy ( &$sql, &$bindParams )

_prefix() protected method

Callback for array_walk to prefix all elements of an array with a given prefix.
protected _prefix ( &$fieldName, $key, $prefix )

_select() protected method

protected _select ( &$sql, &$bindParams )

_where() protected method

protected _where ( &$sql, &$bindParams )

addFields() public method

Adds fields to return with the query.
public addFields ( array $fields, string $fieldPrefix = null ) : Horde_Rdo_Query
$fields array Additional fields to load with this query.
$fieldPrefix string Prefix all field names with this string.
return Horde_Rdo_Query Returns self for fluent method chaining.

addRelationship() public method

Adds a relationship type to a query.
public addRelationship ( string $relationship, array $args ) : Horde_Rdo_Query
$relationship string The name of the relationship as defined in the mapper.
$args array 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.
return Horde_Rdo_Query This object.

addTest() public method

public addTest ( $field, $test, $value )

clearSort() public method

public clearSort ( )

combineWith() public method

public combineWith ( string $conjunction )
$conjunction string SQL conjunction such as "AND", "OR".

create() public static method

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.
public static create ( mixed $query, Horde_Rdo_Mapper $mapper = null ) : Horde_Rdo_Query
$query mixed The query to convert to an object.
$mapper Horde_Rdo_Mapper The Mapper object governing this query.
return Horde_Rdo_Query The full Horde_Rdo_Query object.

distinct() public method

Makes the query return only distinct (different) values.
public distinct ( boolean $distinct ) : Horde_Rdo_Query
$distinct boolean Whether to enable a distinct query.
return Horde_Rdo_Query Returns self for fluent method chaining.

getQuery() public method

Query generator.
public getQuery ( ) : array
return array A two-element array of the SQL query and an array of bind parameters.

limit() public method

Restrict the query to a subset of the results.
public limit ( integer $limit, integer $offset = null )
$limit integer Number of items to fetch.
$offset integer Offset to start fetching at.

setFields() public method

Sets the fields to return with the query.
public setFields ( array $fields, string $fieldPrefix = null ) : Horde_Rdo_Query
$fields array The fields to load with this query.
$fieldPrefix string Prefix all field names with this string.
return Horde_Rdo_Query Returns self for fluent method chaining.

setMapper() public method

public setMapper ( Horde_Rdo_Mapper $mapper ) : Horde_Rdo_Query
$mapper Horde_Rdo_Mapper Rdo mapper base class
return Horde_Rdo_Query Return the query object for fluent chaining.

sortBy() public method

Add a sorting rule.
public sortBy ( string $sort )
$sort string SQL sort fragment, such as 'updated DESC'

Property Details

$_aliasCount protected_oe property

protected int $_aliasCount
return integer

$_aliases protected_oe property

protected array $_aliases
return array

$_sortby protected_oe property

protected array $_sortby
return array

$conjunction public_oe property

public string $conjunction
return string

$distinct public_oe property

public bool $distinct
return boolean

$fields public_oe property

public array $fields
return array

$limit public_oe property

public int $limit
return integer

$limitOffset public_oe property

public int $limitOffset
return integer

$mapper public_oe property

public Horde_Rdo_Mapper $mapper
return Horde_Rdo_Mapper

$relationships public_oe property

public array $relationships
return array

$tests public_oe property

public array $tests
return array