MariaDbGrammar
class MariaDbGrammar extends MySqlGrammar
Traits
Properties
| static protected array | $macros | The registered string macros. |
from Macroable |
| MySqlConnection | $connection | from MySqlGrammar | |
| protected string[] | $operators | The grammar specific operators. |
from MySqlGrammar |
| protected string[] | $bitwiseOperators | The grammar specific bitwise operators. |
from Grammar |
| protected string[] | $selectComponents | The components that make up a select clause. |
from Grammar |
Methods
Mix another object into the class.
Dynamically handle calls to the class.
Dynamically handle calls to the class.
Wrap a table in keyword identifiers.
Wrap a table that has an alias.
Wrap the given JSON selector.
Convert an array of column names into a delimited string.
Get the appropriate query parameter place-holder for a value.
Escape a value for safe SQL embedding.
Split the given JSON selector into the field and the optional path and wrap them separately.
Wrap the given JSON path.
Wrap the given JSON path segment.
Arrange select bindings while retaining legacy group-limit ordering.
Compile the query timeout for a complete select statement.
Format the where clause statements into one string.
Compile a "JSON contains" statement into SQL.
Compile a "JSON overlaps" statement into SQL.
Prepare the binding for a "JSON contains" statement.
Compile a "JSON contains key" statement into SQL.
Compile a "JSON length" statement into SQL.
Compile a "JSON value cast" statement into SQL.
Compile a vector distance expression for the given column.
Determine if the grammar supports vector distance queries.
Compile a having clause involving a bit operator.
Compile a having clause involving an expression.
Compile a row number clause.
Compile an offset, supplying MySQL's unbounded limit when needed.
Compile a union offset independently of the first select's limit.
Compile nested union members using the syntax supported by the server.
Compile an "exists" subquery as a selectable column.
Compile an insert or ignore statement with a returning clause into SQL.
Compile an insert and get ID statement into SQL.
Compile an insert statement using a subquery into SQL.
Compile an insert ignore statement using a subquery into SQL.
Group update values by column in order of first appearance.
Compile an update statement without joins into SQL.
Compile an update statement with joins into SQL.
Compile an "upsert" statement into SQL.
Prepare the bindings for an update statement.
Prepare the bindings for an update statement with joins.
Prepare update values in column order, encoding JSON assignments.
Compile a delete query that does not use joins.
Compile a delete query that uses joins.
Qualify the row identifier selected by a limited or joined write rewrite.
Prepare the bindings for a delete statement.
Compile a query to get the number of open connections for a database.
Compile the SQL statement to execute a savepoint rollback.
Wrap the given JSON selector for boolean values.
Concatenate an array of segments, removing empties.
Remove the leading boolean from a statement.
Substitute the given bindings into the given raw SQL query.
Determine whether to use a legacy group limit clause for MySQL < 8.0.
Prepare a JSON column being updated using the JSON_SET function.
Compile a write target with the query's index hint.
Compile a hinted delete with its target separate from the table reference.
Details
in
Macroable at line 30
static void
macro(string $name, callable|object $macro)
Register a custom macro.
Macros persist in a static property for the worker lifetime and apply to every subsequent call on the macroable class.
in
Macroable at line 44
static void
mixin(object $mixin, bool $replace = true)
Mix another object into the class.
Delegates to macro() for each method; registered macros persist in a static property for the worker lifetime.
in
Macroable at line 61
static bool
hasMacro(string $name)
Check if macro is registered.
in
Macroable at line 72
static void
flushMacros()
Flush the existing macros.
Clears worker-wide macros; concurrent coroutines may resolve different methods depending on timing.
in
Macroable at line 83
static mixed
__callStatic(string $method, array $parameters)
Dynamically handle calls to the class.
in
Macroable at line 108
mixed
__call(string $method, array $parameters)
Dynamically handle calls to the class.
in
Grammar at line 24
__construct(Connection $connection)
Create a new grammar instance.
in
Grammar at line 35
array
wrapArray(array $values)
Wrap an array of values.
in
Grammar at line 43
string
wrapTable(Expression|string $table, string|null $prefix = null)
Wrap a table in keyword identifiers.
in
Grammar at line 76
string
wrapIdentifier(string $value)
Wrap a single identifier in keyword identifiers.
in
Grammar at line 84
string|int|float
wrap(Expression|string $value)
Wrap a value in keyword identifiers.
in
Grammar at line 110
protected string
wrapAliasedValue(string $value)
Wrap a value that has an alias.
in
Grammar at line 120
protected string
wrapAliasedTable(string $value, string|null $prefix = null)
Wrap a table that has an alias.
in
Grammar at line 134
protected string
wrapSegments(array $segments)
Wrap the given value segments.
in
MySqlGrammar at line 656
protected string
wrapValue(string $value)
Wrap a single string in keyword identifiers.
at line 79
protected string
wrapJsonSelector(string $value)
Wrap the given JSON selector.
in
Grammar at line 168
protected bool
isJsonSelector(string $value)
Determine if the given string is a JSON selector.
in
Grammar at line 178
string
columnize(array $columns)
Convert an array of column names into a delimited string.
in
Grammar at line 186
string
parameterize(array $values)
Create query parameter place-holders for an array.
in
Grammar at line 194
string|int|float
parameter(mixed $value)
Get the appropriate query parameter place-holder for a value.
in
MySqlGrammar at line 642
string
quoteString(string|array $value)
Quote the given string literal.
in
Grammar at line 216
string
escape(string|float|int|bool|null $value, bool $binary = false)
Escape a value for safe SQL embedding.
in
Grammar at line 224
bool
isExpression(mixed $value)
Determine if the given value is a raw expression.
in
Grammar at line 232
string|int|float
getValue(Expression|string|int|float $expression)
Transforms expressions to their scalar types.
in
Grammar at line 244
string
getDateFormat()
Get the format for database stored dates.
in
Grammar at line 255
static void
flushState()
Flush all static state.
in
CompilesJsonPaths at line 15
protected array
wrapJsonFieldAndPath(string $column)
Split the given JSON selector into the field and the optional path and wrap them separately.
in
CompilesJsonPaths at line 29
protected string
wrapJsonPath(string $value, string $delimiter = '->')
Wrap the given JSON path.
in
CompilesJsonPaths at line 44
protected string
wrapJsonPathSegment(string $segment)
Wrap the given JSON path segment.
in
MySqlGrammar at line 169
array
prepareBindingsForSelect(Builder $query)
Arrange select bindings while retaining legacy group-limit ordering.
in
Grammar at line 94
protected string
compileSelectQuery(Builder $query)
Compile a select query without statement-level decoration.
Embedded fragments are assembled by their builder's grammar because connection-owned details such as table prefixes resolve through that grammar. They bypass compileSelect because only a complete executed statement carries statement-level decoration.
at line 19
protected string
compileSelectTimeout(Builder $query, string $sql)
Compile the query timeout for a complete select statement.
in
Grammar at line 153
protected array
compileComponents(Builder $query)
Compile the components necessary for a select clause.
in
Grammar at line 173
protected string
compileAggregate(Builder $query, array $aggregate)
Compile an aggregated select clause.
in
Grammar at line 192
protected string|null
compileColumns(Builder $query, array $columns)
Compile the "select *" portion of the query.
in
Grammar at line 213
protected string
compileFrom(Builder $query, Expression|string $table)
Compile the "from" portion of the query.
in
Grammar at line 221
protected string
compileJoins(Builder $query, array $joins)
Compile the "join" portions of the query.
at line 30
string
compileJoinLateral(JoinLateralClause $join, string $expression)
Compile a "lateral join" clause.
in
MySqlGrammar at line 470
protected bool
supportsStraightJoins()
Determine if the grammar supports straight joins.
in
Grammar at line 263
string
compileWheres(Builder $query)
Compile the "where" portions of the query.
in
Grammar at line 281
protected array
compileWheresToArray(Builder $query)
Get an array of all the where clauses for the query.
in
Grammar at line 291
protected string
concatenateWhereClauses(Builder $query, array $sql)
Format the where clause statements into one string.
in
Grammar at line 301
protected string
whereRaw(Builder $query, array $where)
Compile a raw where clause.
in
Grammar at line 309
protected string
whereBasic(Builder $query, array $where)
Compile a basic where clause.
in
MySqlGrammar at line 51
protected string
whereBinary(Builder $query, array $where)
Compile a "where binary" clause.
in
Grammar at line 331
protected string
whereBitwise(Builder $query, array $where)
Compile a bitwise operator where clause.
in
MySqlGrammar at line 61
protected string
whereLike(Builder $query, array $where)
Compile a "where like" clause.
in
Grammar at line 355
protected string
whereIn(Builder $query, array $where)
Compile a "where in" clause.
in
Grammar at line 367
protected string
whereNotIn(Builder $query, array $where)
Compile a "where not in" clause.
in
Grammar at line 381
protected string
whereNotInRaw(Builder $query, array $where)
Compile a "where not in raw" clause.
For safety, whereIntegerInRaw ensures this method is only used with integer values.
in
Grammar at line 395
protected string
whereInRaw(Builder $query, array $where)
Compile a "where in raw" clause.
For safety, whereIntegerInRaw ensures this method is only used with integer values.
in
MySqlGrammar at line 83
protected string
whereNull(Builder $query, array $where)
Add a "where null" clause to the query.
in
MySqlGrammar at line 99
protected string
whereNotNull(Builder $query, array $where)
Add a "where not null" clause to the query.
in
MySqlGrammar at line 75
protected string
whereNullSafeEquals(Builder $query, array $where)
Compile a "where null safe equals" clause.
in
Grammar at line 431
protected string
whereBetween(Builder $query, array $where)
Compile a "between" where clause.
in
Grammar at line 445
protected string
whereBetweenColumns(Builder $query, array $where)
Compile a "between" where clause.
in
Grammar at line 459
protected string
whereValueBetween(Builder $query, array $where)
Compile a "value between" where clause.
in
Grammar at line 473
protected string
whereDate(Builder $query, array $where)
Compile a "where date" clause.
in
Grammar at line 481
protected string
whereTime(Builder $query, array $where)
Compile a "where time" clause.
in
Grammar at line 489
protected string
whereDay(Builder $query, array $where)
Compile a "where day" clause.
in
Grammar at line 497
protected string
whereMonth(Builder $query, array $where)
Compile a "where month" clause.
in
Grammar at line 505
protected string
whereYear(Builder $query, array $where)
Compile a "where year" clause.
in
Grammar at line 513
protected string
dateBasedWhere(string $type, Builder $query, array $where)
Compile a date based where clause.
in
Grammar at line 523
protected string
whereColumn(Builder $query, array $where)
Compile a where clause comparing two columns.
in
Grammar at line 540
protected string
whereNested(Builder $query, array $where)
Compile a nested where clause.
in
Grammar at line 553
protected string
whereSub(Builder $query, array $where)
Compile a where condition with a sub-select.
in
Grammar at line 570
protected string
whereExists(Builder $query, array $where)
Compile a where exists clause.
in
Grammar at line 580
protected string
whereNotExists(Builder $query, array $where)
Compile a where not exists clause.
in
Grammar at line 590
protected string
whereRowValues(Builder $query, array $where)
Compile a where row values condition.
in
Grammar at line 602
protected string
whereJsonBoolean(Builder $query, array $where)
Compile a "where JSON boolean" clause.
in
Grammar at line 623
protected string
whereJsonContains(Builder $query, array $where)
Compile a "where JSON contains" clause.
in
MySqlGrammar at line 254
protected string
compileJsonContains(string $column, string $value)
Compile a "JSON contains" statement into SQL.
in
Grammar at line 646
protected string
whereJsonOverlaps(Builder $query, array $where)
Compile a "where JSON overlaps" clause.
in
MySqlGrammar at line 264
protected string
compileJsonOverlaps(string $column, string $value)
Compile a "JSON overlaps" statement into SQL.
in
Grammar at line 669
mixed
prepareBindingForJsonContains(mixed $binding)
Prepare the binding for a "JSON contains" statement.
in
Grammar at line 677
protected string
whereJsonContainsKey(Builder $query, array $where)
Compile a "where JSON contains key" clause.
in
MySqlGrammar at line 278
protected string
compileJsonContainsKey(string $column)
Compile a "JSON contains key" statement into SQL.
in
Grammar at line 699
protected string
whereJsonLength(Builder $query, array $where)
Compile a "where JSON length" clause.
in
MySqlGrammar at line 288
protected string
compileJsonLength(string $column, string $operator, string $value)
Compile a "JSON length" statement into SQL.
at line 39
string
compileJsonValueCast(string $value)
Compile a "JSON value cast" statement into SQL.
in
MySqlGrammar at line 115
string
whereFullText(Builder $query, array $where)
Compile a "where fulltext" clause.
in
Grammar at line 739
string
whereExpression(Builder $query, array $where)
Compile a clause based on an expression.
at line 55
string
compileVectorDistanceExpression(Expression|string $column)
Compile a vector distance expression for the given column.
at line 63
bool
supportsVectorDistance()
Determine if the grammar supports vector distance queries.
in
Grammar at line 765
protected string
compileGroups(Builder $query, array $groups)
Compile the "group by" portions of the query.
in
Grammar at line 773
protected string
compileHavings(Builder $query)
Compile the "having" portions of the query.
in
Grammar at line 783
protected string
compileHaving(array $having)
Compile a single having clause.
in
Grammar at line 803
protected string
compileBasicHaving(array $having)
Compile a basic having clause.
in
Grammar at line 815
protected string
compileHavingBetween(array $having)
Compile a "between" having clause.
in
Grammar at line 831
protected string
compileHavingNull(array $having)
Compile a having null clause.
in
Grammar at line 841
protected string
compileHavingNotNull(array $having)
Compile a having not null clause.
in
Grammar at line 851
protected string
compileHavingBit(array $having)
Compile a having clause involving a bit operator.
in
Grammar at line 863
protected string
compileHavingExpression(array $having)
Compile a having clause involving an expression.
in
Grammar at line 871
protected string
compileNestedHavings(array $having)
Compile a nested having clause.
in
Grammar at line 879
protected string
compileOrders(Builder $query, array $orders)
Compile the "order by" portions of the query.
in
Grammar at line 891
protected array
compileOrdersToArray(Builder $query, array $orders)
Compile the query orders to an array.
in
Grammar at line 909
protected string
compileInOrderOf(array $order)
Compile an "in order of" clause.
in
MySqlGrammar at line 308
string
compileRandom(string|int $seed)
Compile the random statement into SQL.
in
Grammar at line 933
protected string
compileLimit(Builder $query, int $limit)
Compile the "limit" portions of the query.
in
MySqlGrammar at line 159
protected string
compileGroupLimit(Builder $query)
Compile a group limit clause.
in
Grammar at line 979
protected string
compileRowNumber(string $partition, string $orders)
Compile a row number clause.
in
MySqlGrammar at line 324
protected string
compileOffset(Builder $query, int $offset)
Compile an offset, supplying MySQL's unbounded limit when needed.
in
Grammar at line 997
protected string
compileUnions(Builder $query)
Compile the "union" queries attached to the main query.
in
MySqlGrammar at line 352
protected string
compileUnionOffset(Builder $query, int $offset)
Compile a union offset independently of the first select's limit.
in
MySqlGrammar at line 333
protected string
compileUnion(array $union)
Compile nested union members using the syntax supported by the server.
in
Grammar at line 1044
protected string
wrapUnion(string $sql)
Wrap a union subquery in parentheses.
in
Grammar at line 1052
protected string
compileUnionAggregate(Builder $query)
Compile a union aggregate query into SQL.
in
Grammar at line 1077
string
compileExistsColumn(string $sql)
Compile an "exists" subquery as a selectable column.
in
MySqlGrammar at line 379
string
compileInsert(Builder $query, array $values)
Compile an insert statement into SQL.
in
MySqlGrammar at line 238
string
compileInsertOrIgnore(Builder $query, array $values)
Compile an insert ignore statement into SQL.
in
Grammar at line 1127
string
compileInsertOrIgnoreReturning(Builder $query, array $values, array $returning, array|null $uniqueBy)
Compile an insert or ignore statement with a returning clause into SQL.
in
Grammar at line 1135
string
compileInsertGetId(Builder $query, array $values, string|null $sequence)
Compile an insert and get ID statement into SQL.
in
Grammar at line 1143
string
compileInsertUsing(Builder $query, array $columns, string $sql)
Compile an insert statement using a subquery into SQL.
in
MySqlGrammar at line 246
string
compileInsertOrIgnoreUsing(Builder $query, array $columns, string $sql)
Compile an insert ignore statement using a subquery into SQL.
in
Grammar at line 1167
string
compileUpdate(Builder $query, array $values)
Compile an update statement into SQL.
in
MySqlGrammar at line 391
protected string
compileUpdateColumns(Builder $query, array $values)
Compile the columns for an update statement.
in
MySqlGrammar at line 417
protected array
groupJsonColumnsForUpdate(array $values)
Group update values by column in order of first appearance.
in
MySqlGrammar at line 502
protected string
compileUpdateWithoutJoins(Builder $query, string $table, string $columns, string $where)
Compile an update statement without joins into SQL.
in
MySqlGrammar at line 520
protected string
compileUpdateWithJoins(Builder $query, string $table, string $columns, string $where)
Compile an update statement with joins into SQL.
in
MySqlGrammar at line 434
string
compileUpsert(Builder $query, array $values, array $uniqueBy, array $update)
Compile an "upsert" statement into SQL.
in
MySqlGrammar at line 540
array
prepareBindingsForUpdate(array $bindings, array $values)
Prepare the bindings for an update statement.
Booleans, integers, and doubles are inserted into JSON updates as raw values.
in
MySqlGrammar at line 554
array
prepareBindingsForUpdateWithJoins(array $bindings, array $values)
Prepare the bindings for an update statement with joins.
in
Grammar at line 1273
protected array
prepareValueBindingsForUpdate(array $values)
Prepare update values in column order, encoding JSON assignments.
in
MySqlGrammar at line 570
protected string
compileDeleteWithoutJoins(Builder $query, string $table, string $where)
Compile a delete query that does not use joins.
in
MySqlGrammar at line 600
protected string
compileDeleteWithJoins(Builder $query, string $table, string $where)
Compile a delete query that uses joins.
Adds ORDER BY and LIMIT if present, for platforms that allow them (e.g., PlanetScale). Standard MySQL does not support ORDER BY or LIMIT with joined deletes and will throw a syntax error.
in
Grammar at line 1337
protected string
qualifyRowIdentifier(Builder $query, string $identifier)
Qualify the row identifier selected by a limited or joined write rewrite.
in
Grammar at line 1357
array
prepareBindingsForDelete(array $bindings)
Prepare the bindings for a delete statement.
in
Grammar at line 1367
array
compileTruncate(Builder $query)
Compile a truncate table statement into SQL.
in
MySqlGrammar at line 361
protected string
compileLock(Builder $query, bool|string $value)
Compile the lock into SQL.
at line 47
string|null
compileThreadCount()
Compile a query to get the number of open connections for a database.
in
Grammar at line 1391
bool
supportsSavepoints()
Determine if the grammar supports savepoints.
in
Grammar at line 1399
string
compileSavepoint(string $name)
Compile the SQL statement to define a savepoint.
in
Grammar at line 1407
string
compileSavepointRollBack(string $name)
Compile the SQL statement to execute a savepoint rollback.
in
MySqlGrammar at line 674
protected string
wrapJsonBooleanSelector(string $value)
Wrap the given JSON selector for boolean values.
in
Grammar at line 1423
protected string
wrapJsonBooleanValue(string $value)
Wrap the given JSON boolean value.
in
Grammar at line 1431
protected string
concatenate(array $segments)
Concatenate an array of segments, removing empties.
in
Grammar at line 1441
protected string
removeLeadingBoolean(string $value)
Remove the leading boolean from a statement.
in
Grammar at line 1449
string
substituteBindingsIntoRawSql(string $sql, array $bindings)
Substitute the given bindings into the given raw SQL query.
in
Grammar at line 1496
array
getOperators()
Get the grammar specific operators.
in
Grammar at line 1506
array
getBitwiseOperators()
Get the grammar specific bitwise operators.
in
MySqlGrammar at line 137
protected string
compileIndexHint(Builder $query, IndexHint $indexHint)
Compile the index hints for the query.
at line 71
bool
useLegacyGroupLimit(Builder $query)
Determine whether to use a legacy group limit clause for MySQL < 8.0.
in
MySqlGrammar at line 193
protected string
compileLegacyGroupLimit(Builder $query)
Compile a group limit clause for MySQL < 8.0.
Derived from https://softonsofa.com/tweaking-eloquent-relations-how-to-get-n-related-models-per-parent/.
in
MySqlGrammar at line 478
protected string
compileJsonUpdateColumn(string $key, array $values)
Prepare a JSON column being updated using the JSON_SET function.
in
MySqlGrammar at line 528
protected string
compileTableWithIndexHint(Builder $query, string $table)
Compile a write target with the query's index hint.
in
MySqlGrammar at line 620
protected string
compileDeleteWithIndexHint(Builder $query, string $table, string $where)
Compile a hinted delete with its target separate from the table reference.