Documentation

BaseQuery
in package
implements Query

Tags
category

Horde

Interfaces, Classes, Traits and Enums

Query

Table of Contents

$conjunction  : string
$distinct  : bool
$fields  : array<string|int, mixed>
$limit  : int
$limitOffset  : int
$mapper  : Mapper
$relationships  : array<string|int, mixed>
$sortby  : mixed
$tests  : array<string|int, mixed>
$_aliasCount  : int
$_aliases  : array<string|int, mixed>
$_sortby  : array<string|int, mixed>
__construct()  : mixed
Constructor.
__get()  : mixed
Accessor for any fields that we want some logic around.
addFields()  : Query
Adds fields to return with the query.
addRelationship()  : Query
Adds a relationship type to a query.
addTest()  : mixed
clearSort()  : mixed
combineWith()  : mixed
create()  : Query
Turn any of the acceptable query shorthands into a full Query object. If you pass an existing Query object in, it will be cloned before it's returned so that it can be safely modified.
distinct()  : Query
Makes the query return only distinct (different) values.
getQuery()  : array<string|int, mixed>
Query generator.
limit()  : mixed
Restrict the query to a subset of the results.
setFields()  : Query
Sets the fields to return with the query.
setMapper()  : Query
sortBy()  : mixed
Add a sorting rule.
_alias()  : mixed
Get a unique table alias
_fillJoinPlaceholders()  : array<string|int, mixed>
Take a query array and replace @field@ placeholders with values that will match in the load query.
_from()  : mixed
_join()  : mixed
_limit()  : mixed
_orderBy()  : mixed
_prefix()  : mixed
Callback for array_walk to prefix all elements of an array with a given prefix.
_select()  : mixed
_where()  : mixed

Properties

$conjunction

public string $conjunction = 'AND'

$fields

public array<string|int, mixed> $fields = array('*')

$relationships

public array<string|int, mixed> $relationships = array()

$tests

public array<string|int, mixed> $tests = array()

$_aliases

protected array<string|int, mixed> $_aliases = array()

$_sortby

protected array<string|int, mixed> $_sortby = array()

Methods

__construct()

Constructor.

public __construct([Mapper $mapper = null ]) : mixed
Parameters
$mapper : Mapper = null

Rdo mapper base class

Tags
todo

Make $mapper non-optional in H6

Return values
mixed

__get()

Accessor for any fields that we want some logic around.

public __get(string $key) : mixed
Parameters
$key : string
Return values
mixed

addFields()

Adds fields to return with the query.

public addFields(array<string|int, mixed> $fields[, string $fieldPrefix = null ]) : Query
Parameters
$fields : array<string|int, mixed>

Additional fields to load with this query.

$fieldPrefix : string = null

Prefix all field names with this string.

Return values
Query

Returns self for fluent method chaining.

addRelationship()

Adds a relationship type to a query.

public addRelationship(string $relationship, array<string|int, mixed> $args) : Query
Parameters
$relationship : string

The name of the relationship as defined in the mapper.

$args : array<string|int, mixed>

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 values
Query

This object.

addTest()

public addTest(mixed $field, mixed $test, mixed $value) : mixed
Parameters
$field : mixed
$test : mixed
$value : mixed
Return values
mixed

clearSort()

public clearSort() : mixed
Return values
mixed

combineWith()

public combineWith(string $conjunction) : mixed
Parameters
$conjunction : string

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

Return values
mixed

create()

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

public static create(mixed $query[, Mapper $mapper = null ]) : Query
Parameters
$query : mixed

The query to convert to an object.

$mapper : Mapper = null

The Mapper object governing this query.

Tags
todo

Make $mapper non-optional in H6

Return values
Query

The full Query object.

distinct()

Makes the query return only distinct (different) values.

public distinct(bool $distinct) : Query
Parameters
$distinct : bool

Whether to enable a distinct query.

Return values
Query

Returns self for fluent method chaining.

getQuery()

Query generator.

public getQuery() : array<string|int, mixed>
Return values
array<string|int, mixed>

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

limit()

Restrict the query to a subset of the results.

public limit(int $limit[, int $offset = null ]) : mixed
Parameters
$limit : int

Number of items to fetch.

$offset : int = null

Offset to start fetching at.

Return values
mixed

setFields()

Sets the fields to return with the query.

public setFields(array<string|int, mixed> $fields[, string $fieldPrefix = null ]) : Query
Parameters
$fields : array<string|int, mixed>

The fields to load with this query.

$fieldPrefix : string = null

Prefix all field names with this string.

Return values
Query

Returns self for fluent method chaining.

setMapper()

public setMapper(Mapper $mapper) : Query
Parameters
$mapper : Mapper

Rdo mapper base class

Return values
Query

Return the query object for fluent chaining.

sortBy()

Add a sorting rule.

public sortBy(string $sort) : mixed
Parameters
$sort : string

SQL sort fragment, such as 'updated DESC'

Return values
mixed

_alias()

Get a unique table alias

protected _alias(mixed $tableName) : mixed
Parameters
$tableName : mixed
Return values
mixed

_fillJoinPlaceholders()

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

protected _fillJoinPlaceholders(Mapper $m1, Mapper $m2, array<string|int, mixed> $query) : array<string|int, mixed>
Parameters
$m1 : Mapper

Left-hand mapper

$m2 : Mapper

Right-hand mapper

$query : array<string|int, mixed>

The query to process placeholders on.

Return values
array<string|int, mixed>

The query with placeholders filled in.

_from()

protected _from(mixed &$sql, mixed &$bindParams) : mixed
Parameters
$sql : mixed
$bindParams : mixed
Return values
mixed

_join()

protected _join(mixed &$sql, mixed &$bindParams) : mixed
Parameters
$sql : mixed
$bindParams : mixed
Return values
mixed

_limit()

protected _limit(mixed &$sql, mixed &$bindParams) : mixed
Parameters
$sql : mixed
$bindParams : mixed
Return values
mixed

_orderBy()

protected _orderBy(mixed &$sql, mixed &$bindParams) : mixed
Parameters
$sql : mixed
$bindParams : mixed
Return values
mixed

_prefix()

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

protected _prefix(mixed &$fieldName, mixed $key, mixed $prefix) : mixed
Parameters
$fieldName : mixed
$key : mixed
$prefix : mixed
Return values
mixed

_select()

protected _select(mixed &$sql, mixed &$bindParams) : mixed
Parameters
$sql : mixed
$bindParams : mixed
Return values
mixed

_where()

protected _where(mixed &$sql, mixed &$bindParams) : mixed
Parameters
$sql : mixed
$bindParams : mixed
Return values
mixed

Search results