|
Elgg
Version 7.1
|
Database abstraction query builder. More...
Public Member Functions | |
| __construct (protected readonly Connection $backup_connection) | |
| Initializes a new QueryBuilder. More... | |
| getConnection () | |
| Returns the connection. More... | |
| subquery (string $table, ?string $alias=null) | |
| Creates a new SelectQueryBuilder for join/where sub queries using the DB connection of the primary QueryBuilder. More... | |
| addClause (Clause $clause, ?string $alias=null) | |
| Apply clause to this instance. More... | |
| prefix (string $table) | |
| Prefixes the table name with installation DB prefix. More... | |
| getTableName () | |
| Returns the name of the primary table. More... | |
| getTableAlias () | |
| Returns the alias of the primary table. More... | |
| param ($value, string $type=ELGG_VALUE_STRING, ?string $key=null) | |
| Sets a new parameter assigning it a unique parameter key/name if none provided Returns the name of the new parameter. More... | |
| execute (bool $track_query=true) | |
| Execute the database query for this QueryBuilder. More... | |
| executeStatement () | |
| {} More... | |
| from (string $table, ?string $alias=null) | |
| {} More... | |
| insert (string $table) | |
| {} More... | |
| update (string $table) | |
| {} More... | |
| delete (string $table) | |
| {} More... | |
| join (string $fromAlias, string $join, string $alias, ?string $condition=null) | |
| {} More... | |
| innerJoin (string $fromAlias, string $join, string $alias, ?string $condition=null) | |
| {} More... | |
| leftJoin (string $fromAlias, string $join, string $alias, ?string $condition=null) | |
| {} More... | |
| rightJoin (string $fromAlias, string $join, string $alias, ?string $condition=null) | |
| {} More... | |
| orderBy (string $sort, ?string $order=null) | |
| {} More... | |
| addOrderBy (string $sort, ?string $order=null) | |
| {} More... | |
| merge ($parts=null, $boolean='AND') | |
| Merges multiple composite expressions with a boolean. More... | |
| compare (string $x, string $comparison, $y=null, ?string $type=null, ?bool $case_sensitive=null) | |
| Build value comparison clause. More... | |
| between (string $x, $lower=null, $upper=null, ?string $type=null) | |
| Build a between clause. More... | |
| getNextJoinAlias () | |
| Get an index of the next available join alias. More... | |
| joinEntitiesTable (string $from_alias='', string $from_column='guid', ?string $join_type='inner', ?string $joined_alias=null) | |
| Join entity table from alias and return joined table alias. More... | |
| joinMetadataTable (string $from_alias='', string $from_column='guid', $name=null, ?string $join_type='inner', ?string $joined_alias=null) | |
| Join metadata table from alias and return joined table alias. More... | |
| joinAnnotationTable (string $from_alias='', string $from_column='guid', $name=null, ?string $join_type='inner', ?string $joined_alias=null) | |
| Join annotations table from alias and return joined table alias. More... | |
| joinRelationshipTable (string $from_alias='', string $from_column='guid', $name=null, bool $inverse=false, ?string $join_type='inner', ?string $joined_alias=null) | |
| Join relationship table from alias and return joined table alias. More... | |
Public Attributes | |
| const | CALCULATIONS |
Protected Attributes | |
| array | $joins = [] |
| int | $join_index = 0 |
| string | $table_name = null |
| string | $table_alias = null |
Database abstraction query builder.
Definition at line 21 of file QueryBuilder.php.
| Elgg\Database\QueryBuilder::__construct | ( | protected readonly Connection | $backup_connection | ) |
Initializes a new QueryBuilder.
| Connection | $backup_connection | Connection used for this query |
Definition at line 46 of file QueryBuilder.php.
| Elgg\Database\QueryBuilder::addClause | ( | Clause | $clause, |
| ?string | $alias = null |
||
| ) |
Apply clause to this instance.
| Clause | $clause | Clause |
| string | null | $alias | Table alias |
Definition at line 84 of file QueryBuilder.php.
| Elgg\Database\QueryBuilder::addOrderBy | ( | string | $sort, |
| ?string | $order = null |
||
| ) |
{}
Definition at line 332 of file QueryBuilder.php.
| Elgg\Database\QueryBuilder::between | ( | string | $x, |
$lower = null, |
|||
$upper = null, |
|||
| ?string | $type = null |
||
| ) |
Build a between clause.
| string | $x | Comparison value (e.g. prefixed column name) |
| mixed | $lower | Lower bound |
| mixed | $upper | Upper bound |
| null | string | $type | Value type for sanitization/casting |
Definition at line 414 of file QueryBuilder.php.
| Elgg\Database\QueryBuilder::compare | ( | string | $x, |
| string | $comparison, | ||
$y = null, |
|||
| ?string | $type = null, |
||
| ?bool | $case_sensitive = null |
||
| ) |
Build value comparison clause.
| string | $x | Comparison value (e.g. prefixed column name) |
| string | $comparison | Comparison operator |
| mixed | $y | Value to compare against If the value is an array, comparisons will be performed in such as a way as to ensure that either all or none of the elements of the array meet the criteria, e.g. in case of LIKE will return results where at least one element matches the criteria, whereas with NOT LIKE will return results where none of the criteria are met |
| null | string | $type | Value type for sanitization/casting |
| null | bool | $case_sensitive | Use case-sensitive comparison for strings |
Definition at line 400 of file QueryBuilder.php.
| Elgg\Database\QueryBuilder::delete | ( | string | $table | ) |
{}
Definition at line 284 of file QueryBuilder.php.
| Elgg\Database\QueryBuilder::execute | ( | bool | $track_query = true | ) |
Execute the database query for this QueryBuilder.
| bool | $track_query | should the query be tracked by timers and loggers |
Definition at line 218 of file QueryBuilder.php.
| Elgg\Database\QueryBuilder::executeStatement | ( | ) |
{}
Definition at line 239 of file QueryBuilder.php.
| Elgg\Database\QueryBuilder::from | ( | string | $table, |
| ?string | $alias = null |
||
| ) |
{}
Definition at line 250 of file QueryBuilder.php.
| Elgg\Database\QueryBuilder::getConnection | ( | ) |
Returns the connection.
Need to do it this way because DBAL Query Builder does not expose the connection in 4.x
Definition at line 57 of file QueryBuilder.php.
| Elgg\Database\QueryBuilder::getNextJoinAlias | ( | ) |
Get an index of the next available join alias.
Definition at line 432 of file QueryBuilder.php.
| Elgg\Database\QueryBuilder::getTableAlias | ( | ) |
Returns the alias of the primary table.
Definition at line 131 of file QueryBuilder.php.
| Elgg\Database\QueryBuilder::getTableName | ( | ) |
Returns the name of the primary table.
Definition at line 122 of file QueryBuilder.php.
| Elgg\Database\QueryBuilder::innerJoin | ( | string | $fromAlias, |
| string | $join, | ||
| string | $alias, | ||
| ?string | $condition = null |
||
| ) |
{}
Definition at line 300 of file QueryBuilder.php.
| Elgg\Database\QueryBuilder::insert | ( | string | $table | ) |
{}
Definition at line 262 of file QueryBuilder.php.
| Elgg\Database\QueryBuilder::join | ( | string | $fromAlias, |
| string | $join, | ||
| string | $alias, | ||
| ?string | $condition = null |
||
| ) |
{}
Definition at line 293 of file QueryBuilder.php.
| Elgg\Database\QueryBuilder::joinAnnotationTable | ( | string | $from_alias = '', |
| string | $from_column = 'guid', |
||
$name = null, |
|||
| ?string | $join_type = 'inner', |
||
| ?string | $joined_alias = null |
||
| ) |
Join annotations table from alias and return joined table alias.
| string | $from_alias | Main table alias |
| string | $from_column | Guid column name in the main table |
| string | string[] | $name | Annotation name |
| string | null | $join_type | JOIN type |
| string | null | $joined_alias | Joined table alias |
Definition at line 537 of file QueryBuilder.php.
| Elgg\Database\QueryBuilder::joinEntitiesTable | ( | string | $from_alias = '', |
| string | $from_column = 'guid', |
||
| ?string | $join_type = 'inner', |
||
| ?string | $joined_alias = null |
||
| ) |
Join entity table from alias and return joined table alias.
| string | $from_alias | Main table alias |
| string | $from_column | Guid column name in the main table |
| string | null | $join_type | JOIN type |
| string | null | $joined_alias | Joined table alias |
Definition at line 448 of file QueryBuilder.php.
| Elgg\Database\QueryBuilder::joinMetadataTable | ( | string | $from_alias = '', |
| string | $from_column = 'guid', |
||
$name = null, |
|||
| ?string | $join_type = 'inner', |
||
| ?string | $joined_alias = null |
||
| ) |
Join metadata table from alias and return joined table alias.
| string | $from_alias | Alias of the main table |
| string | $from_column | Guid column name in the main table |
| string | string[] | $name | Metadata name(s) |
| string | null | $join_type | JOIN type |
| string | null | $joined_alias | Joined table alias |
Definition at line 490 of file QueryBuilder.php.
| Elgg\Database\QueryBuilder::joinRelationshipTable | ( | string | $from_alias = '', |
| string | $from_column = 'guid', |
||
$name = null, |
|||
| bool | $inverse = false, |
||
| ?string | $join_type = 'inner', |
||
| ?string | $joined_alias = null |
||
| ) |
Join relationship table from alias and return joined table alias.
| string | $from_alias | Main table alias |
| string | $from_column | Guid column name in the main table |
| string | $name | Relationship name |
| bool | $inverse | Join on guid_two column |
| string | null | $join_type | JOIN type |
| string | null | $joined_alias | Joined table alias |
Definition at line 585 of file QueryBuilder.php.
| Elgg\Database\QueryBuilder::leftJoin | ( | string | $fromAlias, |
| string | $join, | ||
| string | $alias, | ||
| ?string | $condition = null |
||
| ) |
{}
Definition at line 307 of file QueryBuilder.php.
| Elgg\Database\QueryBuilder::merge | ( | $parts = null, |
|
$boolean = 'AND' |
|||
| ) |
Merges multiple composite expressions with a boolean.
| mixed | $parts | Composite expression(s) or string(s) |
| string | $boolean | AND|OR |
Definition at line 348 of file QueryBuilder.php.
| Elgg\Database\QueryBuilder::orderBy | ( | string | $sort, |
| ?string | $order = null |
||
| ) |
{}
Definition at line 321 of file QueryBuilder.php.
| Elgg\Database\QueryBuilder::param | ( | $value, | |
| string | $type = ELGG_VALUE_STRING, |
||
| ?string | $key = null |
||
| ) |
Sets a new parameter assigning it a unique parameter key/name if none provided Returns the name of the new parameter.
| mixed | $value | Parameter value |
| string | $type | Parameter type |
| string | null | $key | Parameter key/index |
Definition at line 145 of file QueryBuilder.php.
| Elgg\Database\QueryBuilder::prefix | ( | string | $table | ) |
Prefixes the table name with installation DB prefix.
| string | $table | the table to prefix |
Definition at line 104 of file QueryBuilder.php.
| Elgg\Database\QueryBuilder::rightJoin | ( | string | $fromAlias, |
| string | $join, | ||
| string | $alias, | ||
| ?string | $condition = null |
||
| ) |
{}
Definition at line 314 of file QueryBuilder.php.
| Elgg\Database\QueryBuilder::subquery | ( | string | $table, |
| ?string | $alias = null |
||
| ) |
Creates a new SelectQueryBuilder for join/where sub queries using the DB connection of the primary QueryBuilder.
| string | $table | Main table name |
| string | null | $alias | Select alias |
Definition at line 69 of file QueryBuilder.php.
| Elgg\Database\QueryBuilder::update | ( | string | $table | ) |
{}
Definition at line 273 of file QueryBuilder.php.
|
protected |
Definition at line 35 of file QueryBuilder.php.
|
protected |
Definition at line 33 of file QueryBuilder.php.
|
protected |
Definition at line 39 of file QueryBuilder.php.
|
protected |
Definition at line 37 of file QueryBuilder.php.
| const Elgg\Database\QueryBuilder::CALCULATIONS |
Definition at line 23 of file QueryBuilder.php.