Query
class Query
Constants
| BOOLEAN_AND |
|
| BOOLEAN_OR |
|
| SORT_ASCENDING |
|
| SORT_DESCENDING |
|
| RETURN_FULL_QUERY |
|
| RETURN_WHERE |
|
Methods
Query constructor.
Returns a String representation (SQL Query String) - depending on the defaultStringReturn setting this may be the whole SQL or only the WHERE condition SQL
Internal use function to copy ScopeOrder to other Query
Clears all scopes and conditions
Escapes the passed mysql fieldname with backticks
Escapes the passed value for using it in a mysql query
Execute Query and return Resultset
No description
Return ORDER BY part of the query
Returns the full SQL string for this Query
Return Limit
Returns an array with all defined Conditions
Returns an array with all defined Conditions
Builds the SELECT SQL
No description
No description
Checks if a condition for the specified field is specified NOTE: This check does not (yet) cover whereRaw() conditions with custom syntaxes
Builds the WHERE Condition SQL
No description
Check if a specific whereScope has been applied to the collection
Add join based on simple condition.
Adds a join condition to the previous defined join, e.g.: AND {$baseTable}.{$baseTableField} = {$joinTable}.{$joinTableField}
Add basic inner join based on simple condition
Add basic inner join based on simple condition
Set Limit on Query
Always evaluates the scope to FALSE and can be used to force returning an empty collection in some filter conditions
Adds a orderBy condition to the Query
Applies all ORDER conditions of the passed Query object to the current query (Copy)
Removes a SELECT field from the query.
No description
Resets orderBy condition of the Query
Reset Select Fields
Adds a SELECT field from a specific table to the query
Adds a custom SELECT SQL to the query
Sets the default return if Object is converted to a STRING
Registeres a Callback which is executed if the Query is being changed
Syntax-Helper to start a query with for a table. Use as Query::table('myTable')->where('field1','=','val');
Trigger onChange event callbacks
Removes all scope conditions which are set in the passed Query object (similar to boolean subtract)
Removes all Where Conditions or the Conditions for a specific field
Adds a custom WHERE Condition to the query
Adds a EQUAL WHERE Condition to the query
Applies all WHERE conditions of the passed Query object to the current query (Copy)
Adds a custom NEGATED WHERE Condition to the query
Adds a NEGATED EQUAL WHERE Condition to the query
Use automatic field conversion of timestamp and binary fields, requires tableSchema
No description
Details
at line 73
__construct(string $table, array $tableSchema = [])
Query constructor.
at line 556
string
__toString()
Returns a String representation (SQL Query String) - depending on the defaultStringReturn setting this may be the whole SQL or only the WHERE condition SQL
at line 600
array
_getScopeOrderBy()
Internal use function to copy ScopeOrder to other Query
at line 447
void
clear()
Clears all scopes and conditions
at line 746
static string
escapeField(string|null $field)
Escapes the passed mysql fieldname with backticks
at line 762
static string
escapeValue(string|null $value)
Escapes the passed value for using it in a mysql query
at line 1002
array
execute(bool $i18nMode = false)
Execute Query and return Resultset
at line 939
array
getJoins()
No description
at line 588
string
getOrderBySQL()
Return ORDER BY part of the query
at line 548
string
getSQL()
Returns the full SQL string for this Query
at line 608
array
getScopeLimit()
Return Limit
at line 573
array
getScopeWhere()
Returns an array with all defined Conditions
at line 580
array
getScopeWhereGroup()
Returns an array with all defined Conditions
at line 665
string
getSelectSQL()
Builds the SELECT SQL
at line 727
array
getSelectedFields()
No description
at line 731
string
getTable()
No description
at line 620
array
getWhereConditionsForField($field)
Checks if a condition for the specified field is specified NOTE: This check does not (yet) cover whereRaw() conditions with custom syntaxes
at line 630
string
getWhereSQL(string|null $table = null)
Builds the WHERE Condition SQL
at line 389
Query
groupBy(string $field)
Add a group by condition to the Query
at line 935
bool
hasJoins()
No description
at line 507
bool
hasScopeWhere(string $scopeField)
Check if a specific whereScope has been applied to the collection
at line 864
Query
join(string $baseTable, string $baseTableField, string $joinTable, string $joinTableField, string $joinType = 'LEFT JOIN', string $conditionOperator = '=')
Add join based on simple condition.
{$joinType} {$joinTable} ON ({$baseTable}.{$queryField} = {$joinTable}.{$joinTableField})
at line 900
Query
joinAddCondition(string $baseTable, string $baseTableField, string|null $joinTable, string|int $joinTableField, string $conditionOperator = '=', string $concatToPreviousConditionOperand = Query::BOOLEAN_AND)
Adds a join condition to the previous defined join, e.g.: AND {$baseTable}.{$baseTableField} = {$joinTable}.{$joinTableField}
If no joinTable is defined (null) the $joinTableField will be treated as value: AND {$baseTable}.{$baseTableField} = '{$joinTableField}'
at line 835
Query
joinInner(string $queryField, string $joinTable, string $joinTableField)
Add basic inner join based on simple condition
at line 848
Query
joinLeft(string $queryField, string $joinTable, string $joinTableField)
Add basic inner join based on simple condition
at line 364
$this
limit(int $length, int $offset = 0)
Set Limit on Query
at line 376
Query
none()
Always evaluates the scope to FALSE and can be used to force returning an empty collection in some filter conditions
at line 425
Query
orderBy(string $field, string $sortDirection = self::SORT_ASCENDING, string|null $fieldAlias = null)
Adds a orderBy condition to the Query
at line 350
Query
orderFromQuery(Query $query)
Applies all ORDER conditions of the passed Query object to the current query (Copy)
at line 151
Query
removeSelectField(string $field)
Removes a SELECT field from the query.
at line 410
Query
resetLimit()
No description
at line 401
Query
resetOrderBy()
Resets orderBy condition of the Query
at line 206
Query
resetSelectedFields()
Reset Select Fields
at line 134
Query
select(string $selectField, string $aliasAs = null)
Adds a SELECT field to the query
at line 167
Query
selectFromTable(string $selectField, string $table, string $aliasAs = null)
Adds a SELECT field from a specific table to the query
at line 188
Query
selectRaw(string $selectSql, string $aliasAs = null, string|null $fieldReference = null)
Adds a custom SELECT SQL to the query
at line 105
void
setDefaultStringReturn($returnType)
Sets the default return if Object is converted to a STRING
at line 85
void
setOnChangeCallback(callable $callback)
Registeres a Callback which is executed if the Query is being changed
at line 122
static Query
table(string $table, array $tableSchema = [])
Syntax-Helper to start a query with for a table. Use as Query::table('myTable')->where('field1','=','val');
at line 93
void
triggerOnChange()
Trigger onChange event callbacks
at line 464
Query
unscope(string $what = 'all')
Unscope Function to remove specific scopes of the query
at line 524
Query
unscopeFromQuery(Query $Query)
Removes all scope conditions which are set in the passed Query object (similar to boolean subtract)
at line 489
Query
unscopeWhere(string $unscopeSpecificField = null)
Removes all Where Conditions or the Conditions for a specific field
at line 229
Query
where(string $field, string $condition, string $value = null)
Adds a custom WHERE Condition to the query
at line 316
Query
whereConditionGroup(ConditionGroup $conditionGroup)
Adds a Condition object as condition
at line 254
Query
whereEqual(string $field, string|array $value)
Adds a EQUAL WHERE Condition to the query
at line 332
Query
whereFromQuery(Query $query)
Applies all WHERE conditions of the passed Query object to the current query (Copy)
at line 278
Query
whereLike(string $field, string $value)
Adds a LIKE Condition to the query
at line 242
Query
whereNot(string $field, string $condition, string $value = null)
Adds a custom NEGATED WHERE Condition to the query
at line 266
Query
whereNotEqual(string $field, string|array $value)
Adds a NEGATED EQUAL WHERE Condition to the query
at line 292
Query
whereRaw($rawSQL)
Adds a RAW WHERE Condition to the query
at line 783
Query
withAutoSelects()
Use automatic field conversion of timestamp and binary fields, requires tableSchema
at line 816
Query
withDistinctSelect()
No description