MediaWiki master
|
A query builder for UNION queries takes SelectQueryBuilder objects. More...
Public Member Functions | |
__construct (IDatabase $db) | |
To create a UnionQueryBuilder instance, use $db->newUnionQueryBuilder() instead. | |
add (SelectQueryBuilder $selectQueryBuilder) | |
Add a select query builder object to the list of union. | |
all () | |
Enable UNION_ALL option, the default is UNION_DISTINCT. | |
caller ( $fname) | |
Set the method name to be included in an SQL comment. | |
fetchField () | |
Run the constructed UNION query, and return a single field extracted from the first result row. | |
fetchFieldValues () | |
Run the constructed UNION query, and extract a single field from each result row, returning an array containing all the values. | |
fetchResultSet () | |
Run the constructed UNION query and return all results. | |
fetchRow () | |
Run the constructed UNION query, and return the first result row. | |
getSQL () | |
Get the SQL query string which would be used by fetchResultSet(). | |
limit ( $limit) | |
Set the query limit. | |
offset ( $offset) | |
Set the offset. | |
orderBy ( $fields, $direction=null) | |
Set the ORDER BY clause. | |
Public Attributes | |
const | SORT_ASC = 'ASC' |
sort the results in ascending order | |
const | SORT_DESC = 'DESC' |
sort the results in descending order | |
A query builder for UNION queries takes SelectQueryBuilder objects.
Any particular query builder object should only be used for a single database query, and not be reused afterwards.
Definition at line 16 of file UnionQueryBuilder.php.
Wikimedia\Rdbms\UnionQueryBuilder::__construct | ( | IDatabase | $db | ) |
To create a UnionQueryBuilder instance, use $db->newUnionQueryBuilder()
instead.
IDatabase | $db |
Definition at line 47 of file UnionQueryBuilder.php.
Wikimedia\Rdbms\UnionQueryBuilder::add | ( | SelectQueryBuilder | $selectQueryBuilder | ) |
Add a select query builder object to the list of union.
Definition at line 56 of file UnionQueryBuilder.php.
Wikimedia\Rdbms\UnionQueryBuilder::all | ( | ) |
Enable UNION_ALL option, the default is UNION_DISTINCT.
Definition at line 66 of file UnionQueryBuilder.php.
References Wikimedia\Rdbms\UnionQueryBuilder\all().
Referenced by Wikimedia\Rdbms\UnionQueryBuilder\all(), and Wikimedia\Rdbms\UnionQueryBuilder\getSQL().
Wikimedia\Rdbms\UnionQueryBuilder::caller | ( | $fname | ) |
Set the method name to be included in an SQL comment.
string | $fname |
Definition at line 165 of file UnionQueryBuilder.php.
References Wikimedia\Rdbms\UnionQueryBuilder\caller().
Referenced by Wikimedia\Rdbms\UnionQueryBuilder\caller(), and Wikimedia\Rdbms\UnionQueryBuilder\fetchResultSet().
Wikimedia\Rdbms\UnionQueryBuilder::fetchField | ( | ) |
Run the constructed UNION query, and return a single field extracted from the first result row.
If there were no result rows, false is returned. This may only be called when only one field has been added to the constituent queries.
Definition at line 190 of file UnionQueryBuilder.php.
References Wikimedia\Rdbms\UnionQueryBuilder\fetchResultSet(), and Wikimedia\Rdbms\UnionQueryBuilder\limit().
Wikimedia\Rdbms\UnionQueryBuilder::fetchFieldValues | ( | ) |
Run the constructed UNION query, and extract a single field from each result row, returning an array containing all the values.
This may only be called when only one field has been added to the constituent queries.
Definition at line 212 of file UnionQueryBuilder.php.
References Wikimedia\Rdbms\UnionQueryBuilder\fetchResultSet().
Wikimedia\Rdbms\UnionQueryBuilder::fetchResultSet | ( | ) |
Run the constructed UNION query and return all results.
Definition at line 175 of file UnionQueryBuilder.php.
References Wikimedia\Rdbms\UnionQueryBuilder\caller(), and Wikimedia\Rdbms\UnionQueryBuilder\getSQL().
Referenced by Wikimedia\Rdbms\UnionQueryBuilder\fetchField(), Wikimedia\Rdbms\UnionQueryBuilder\fetchFieldValues(), and Wikimedia\Rdbms\UnionQueryBuilder\fetchRow().
Wikimedia\Rdbms\UnionQueryBuilder::fetchRow | ( | ) |
Run the constructed UNION query, and return the first result row.
If there were no results, return false.
Definition at line 233 of file UnionQueryBuilder.php.
References Wikimedia\Rdbms\UnionQueryBuilder\fetchResultSet(), and Wikimedia\Rdbms\UnionQueryBuilder\limit().
Wikimedia\Rdbms\UnionQueryBuilder::getSQL | ( | ) |
Get the SQL query string which would be used by fetchResultSet().
Definition at line 247 of file UnionQueryBuilder.php.
References Wikimedia\Rdbms\UnionQueryBuilder\all().
Referenced by Wikimedia\Rdbms\UnionQueryBuilder\fetchResultSet().
Wikimedia\Rdbms\UnionQueryBuilder::limit | ( | $limit | ) |
Set the query limit.
Return at most this many rows. The rows are sorted and then the first rows are taken until the limit is reached. Limit is applied to a result set after offset.
If the query builder already has a limit, the old limit will be discarded. This would be also ignored if the DB does not support limit in union queries.
int | $limit |
Definition at line 82 of file UnionQueryBuilder.php.
Referenced by Wikimedia\Rdbms\UnionQueryBuilder\fetchField(), and Wikimedia\Rdbms\UnionQueryBuilder\fetchRow().
Wikimedia\Rdbms\UnionQueryBuilder::offset | ( | $offset | ) |
Set the offset.
Skip this many rows at the start of the result set. Offset with limit() can theoretically be used for paging through a result set, but this is discouraged for performance reasons.
If the query builder already has an offset, the old offset will be discarded. This would be also ignored if the DB does not support offset in union queries.
int | $offset |
Definition at line 101 of file UnionQueryBuilder.php.
Wikimedia\Rdbms\UnionQueryBuilder::orderBy | ( | $fields, | |
$direction = null ) |
Set the ORDER BY clause.
If it has already been set, append the additional fields to it.
This would be ignored if the DB does not support order by in union queries.
string[] | string | $fields | The field or list of fields to order by. |
string | null | $direction | self::SORT_ASC or self::SORT_DESC. If this is null then $fields is assumed to optionally contain ASC or DESC after each field name. |
Definition at line 123 of file UnionQueryBuilder.php.
const Wikimedia\Rdbms\UnionQueryBuilder::SORT_ASC = 'ASC' |
sort the results in ascending order
Definition at line 18 of file UnionQueryBuilder.php.
const Wikimedia\Rdbms\UnionQueryBuilder::SORT_DESC = 'DESC' |
sort the results in descending order
Definition at line 21 of file UnionQueryBuilder.php.