Grammar
class Grammar extends Grammar
Traits
Properties
| static protected array | $macros | The registered string macros. |
from Macroable |
| protected Connection | $connection | The connection used for escaping values. |
from Grammar |
| protected string[] | $operators | The grammar specific operators. |
|
| protected string[] | $bitwiseOperators | The grammar specific bitwise operators. |
|
| protected string[] | $selectComponents | The components that make up a select clause. |
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.
Convert an array of column names into a delimited string.
Get the appropriate query parameter place-holder for a value.
Escapes 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.
Determine if the grammar supports straight joins.
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 single having clause.
Compile a basic having clause.
Compile a "between" having clause.
Compile a having null clause.
Compile a having not null clause.
Compile a having clause involving a bit operator.
Compile a having clause involving an expression.
Compile a nested having clause.
Compile an "in order of" clause.
Compile the random statement into SQL.
Compile a row number clause.
Compile a single union statement.
Wrap a union subquery in parentheses.
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.
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.
Compile a delete statement without joins into SQL.
Compile a delete statement with joins into SQL.
Prepare the bindings for a delete statement.
Compile a query to get the number of open connections for a database.
Determine if the grammar supports savepoints.
Compile the SQL statement to define a savepoint.
Compile the SQL statement to execute a savepoint rollback.
Wrap the given JSON selector for boolean values.
Wrap the given JSON boolean value.
Concatenate an array of segments, removing empties.
Remove the leading boolean from a statement.
Substitute the given bindings into the given raw SQL query.
Get the grammar specific operators.
Get the grammar specific bitwise operators.
Details
in
Macroable at line 28
static void
macro(string $name, callable|object $macro)
Register a custom macro.
Boot-only. Macros persist in a static property for the worker lifetime and apply to every subsequent call on the macroable class.
in
Macroable at line 41
static void
mixin(object $mixin, bool $replace = true)
Mix another object into the class.
Boot-only. Delegates to macro() for each method; registered macros persist in a static property for the worker lifetime.
in
Macroable at line 57
static bool
hasMacro(string $name)
Check if macro is registered.
in
Macroable at line 68
static void
flushMacros()
Flush the existing macros.
Boot or tests only. Clears worker-wide macros; concurrent coroutines may resolve different methods depending on timing.
in
Macroable at line 78
static mixed
__callStatic(string $method, array $parameters)
Dynamically handle calls to the class.
in
Macroable at line 103
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 75
string|int|float
wrap(Expression|string $value)
Wrap a value in keyword identifiers.
in
Grammar at line 101
protected string
wrapAliasedValue(string $value)
Wrap a value that has an alias.
in
Grammar at line 111
protected string
wrapAliasedTable(string $value, string|null $prefix = null)
Wrap a table that has an alias.
in
Grammar at line 125
protected string
wrapSegments(array $segments)
Wrap the given value segments.
in
Grammar at line 137
protected string
wrapValue(string $value)
Wrap a single string in keyword identifiers.
in
Grammar at line 151
protected string
wrapJsonSelector(string $value)
Wrap the given JSON selector.
in
Grammar at line 159
protected bool
isJsonSelector(string $value)
Determine if the given string is a JSON selector.
in
Grammar at line 169
string
columnize(array $columns)
Convert an array of column names into a delimited string.
in
Grammar at line 177
string
parameterize(array $values)
Create query parameter place-holders for an array.
in
Grammar at line 185
string|int|float
parameter(mixed $value)
Get the appropriate query parameter place-holder for a value.
in
Grammar at line 195
string
quoteString(string|array $value)
Quote the given string literal.
in
Grammar at line 207
string
escape(string|float|int|bool|null $value, bool $binary = false)
Escapes a value for safe SQL embedding.
in
Grammar at line 215
bool
isExpression(mixed $value)
Determine if the given value is a raw expression.
in
Grammar at line 223
string|int|float
getValue(Expression|string|int|float $expression)
Transforms expressions to their scalar types.
in
Grammar at line 235
string
getDateFormat()
Get the format for database stored dates.
in
Grammar at line 246
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 43
protected string
wrapJsonPathSegment(string $segment)
Wrap the given JSON path segment.
at line 58
string
compileSelect(Builder $query)
Compile a select query into SQL.
at line 105
protected array
compileComponents(Builder $query)
Compile the components necessary for a select clause.
at line 125
protected string
compileAggregate(Builder $query, array $aggregate)
Compile an aggregated select clause.
at line 144
protected string|null
compileColumns(Builder $query, array $columns)
Compile the "select *" portion of the query.
at line 165
protected string
compileFrom(Builder $query, Expression|string $table)
Compile the "from" portion of the query.
at line 173
protected string
compileJoins(Builder $query, array $joins)
Compile the "join" portions of the query.
at line 197
string
compileJoinLateral(JoinLateralClause $join, string $expression)
Compile a "lateral join" clause.
at line 207
protected bool
supportsStraightJoins()
Determine if the grammar supports straight joins.
at line 215
string
compileWheres(Builder $query)
Compile the "where" portions of the query.
at line 233
protected array
compileWheresToArray(Builder $query)
Get an array of all the where clauses for the query.
at line 243
protected string
concatenateWhereClauses(Builder $query, array $sql)
Format the where clause statements into one string.
at line 253
protected string
whereRaw(Builder $query, array $where)
Compile a raw where clause.
at line 261
protected string
whereBasic(Builder $query, array $where)
Compile a basic where clause.
at line 273
protected string
whereBitwise(Builder $query, array $where)
Compile a bitwise operator where clause.
at line 281
protected string
whereLike(Builder $query, array $where)
Compile a "where like" clause.
at line 295
protected string
whereIn(Builder $query, array $where)
Compile a "where in" clause.
at line 307
protected string
whereNotIn(Builder $query, array $where)
Compile a "where not in" clause.
at line 321
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.
at line 335
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.
at line 347
protected string
whereNull(Builder $query, array $where)
Compile a "where null" clause.
at line 355
protected string
whereNotNull(Builder $query, array $where)
Compile a "where not null" clause.
at line 363
protected string
whereNullSafeEquals(Builder $query, array $where)
Compile a "where null safe equals" clause.
at line 371
protected string
whereBetween(Builder $query, array $where)
Compile a "between" where clause.
at line 385
protected string
whereBetweenColumns(Builder $query, array $where)
Compile a "between" where clause.
at line 399
protected string
whereValueBetween(Builder $query, array $where)
Compile a "value between" where clause.
at line 413
protected string
whereDate(Builder $query, array $where)
Compile a "where date" clause.
at line 421
protected string
whereTime(Builder $query, array $where)
Compile a "where time" clause.
at line 429
protected string
whereDay(Builder $query, array $where)
Compile a "where day" clause.
at line 437
protected string
whereMonth(Builder $query, array $where)
Compile a "where month" clause.
at line 445
protected string
whereYear(Builder $query, array $where)
Compile a "where year" clause.
at line 453
protected string
dateBasedWhere(string $type, Builder $query, array $where)
Compile a date based where clause.
at line 463
protected string
whereColumn(Builder $query, array $where)
Compile a where clause comparing two columns.
at line 473
protected string
whereNested(Builder $query, array $where)
Compile a nested where clause.
at line 486
protected string
whereSub(Builder $query, array $where)
Compile a where condition with a sub-select.
at line 496
protected string
whereExists(Builder $query, array $where)
Compile a where exists clause.
at line 504
protected string
whereNotExists(Builder $query, array $where)
Compile a where not exists clause.
at line 512
protected string
whereRowValues(Builder $query, array $where)
Compile a where row values condition.
at line 524
protected string
whereJsonBoolean(Builder $query, array $where)
Compile a "where JSON boolean" clause.
at line 538
protected string
whereJsonContains(Builder $query, array $where)
Compile a "where JSON contains" clause.
at line 553
protected string
compileJsonContains(string $column, string $value)
Compile a "JSON contains" statement into SQL.
at line 561
protected string
whereJsonOverlaps(Builder $query, array $where)
Compile a "where JSON overlaps" clause.
at line 576
protected string
compileJsonOverlaps(string $column, string $value)
Compile a "JSON overlaps" statement into SQL.
at line 584
mixed
prepareBindingForJsonContains(mixed $binding)
Prepare the binding for a "JSON contains" statement.
at line 592
protected string
whereJsonContainsKey(Builder $query, array $where)
Compile a "where JSON contains key" clause.
at line 606
protected string
compileJsonContainsKey(string $column)
Compile a "JSON contains key" statement into SQL.
at line 614
protected string
whereJsonLength(Builder $query, array $where)
Compile a "where JSON length" clause.
at line 628
protected string
compileJsonLength(string $column, string $operator, string $value)
Compile a "JSON length" statement into SQL.
at line 636
string
compileJsonValueCast(string $value)
Compile a "JSON value cast" statement into SQL.
at line 644
string
whereFullText(Builder $query, array $where)
Compile a "where fulltext" clause.
at line 652
string
whereExpression(Builder $query, array $where)
Compile a clause based on an expression.
at line 660
protected string
compileGroups(Builder $query, array $groups)
Compile the "group by" portions of the query.
at line 668
protected string
compileHavings(Builder $query)
Compile the "having" portions of the query.
at line 678
protected string
compileHaving(array $having)
Compile a single having clause.
at line 698
protected string
compileBasicHaving(array $having)
Compile a basic having clause.
at line 710
protected string
compileHavingBetween(array $having)
Compile a "between" having clause.
at line 726
protected string
compileHavingNull(array $having)
Compile a having null clause.
at line 736
protected string
compileHavingNotNull(array $having)
Compile a having not null clause.
at line 746
protected string
compileHavingBit(array $having)
Compile a having clause involving a bit operator.
at line 758
protected string
compileHavingExpression(array $having)
Compile a having clause involving an expression.
at line 766
protected string
compileNestedHavings(array $having)
Compile a nested having clause.
at line 774
protected string
compileOrders(Builder $query, array $orders)
Compile the "order by" portions of the query.
at line 786
protected array
compileOrdersToArray(Builder $query, array $orders)
Compile the query orders to an array.
at line 804
protected string
compileInOrderOf(array $order)
Compile an "in order of" clause.
at line 820
string
compileRandom(string|int $seed)
Compile the random statement into SQL.
at line 828
protected string
compileLimit(Builder $query, int $limit)
Compile the "limit" portions of the query.
at line 836
protected string
compileGroupLimit(Builder $query)
Compile a group limit clause.
at line 879
protected string
compileRowNumber(string $partition, string $orders)
Compile a row number clause.
at line 889
protected string
compileOffset(Builder $query, int $offset)
Compile the "offset" portions of the query.
at line 897
protected string
compileUnions(Builder $query)
Compile the "union" queries attached to the main query.
at line 923
protected string
compileUnion(array $union)
Compile a single union statement.
at line 933
protected string
wrapUnion(string $sql)
Wrap a union subquery in parentheses.
at line 941
protected string
compileUnionAggregate(Builder $query)
Compile a union aggregate query into SQL.
at line 953
string
compileExists(Builder $query)
Compile an exists statement into SQL.
at line 963
string
compileInsert(Builder $query, array $values)
Compile an insert statement into SQL.
at line 995
string
compileInsertOrIgnore(Builder $query, array $values)
Compile an insert ignore statement into SQL.
at line 1005
string
compileInsertOrIgnoreReturning(Builder $query, array $values, array $returning, array|null $uniqueBy)
Compile an insert or ignore statement with a returning clause into SQL.
at line 1013
string
compileInsertGetId(Builder $query, array $values, string|null $sequence)
Compile an insert and get ID statement into SQL.
at line 1021
string
compileInsertUsing(Builder $query, array $columns, string $sql)
Compile an insert statement using a subquery into SQL.
at line 1037
string
compileInsertOrIgnoreUsing(Builder $query, array $columns, string $sql)
Compile an insert ignore statement using a subquery into SQL.
at line 1045
string
compileUpdate(Builder $query, array $values)
Compile an update statement into SQL.
at line 1063
protected string
compileUpdateColumns(Builder $query, array $values)
Compile the columns for an update statement.
at line 1073
protected string
compileUpdateWithoutJoins(Builder $query, string $table, string $columns, string $where)
Compile an update statement without joins into SQL.
at line 1081
protected string
compileUpdateWithJoins(Builder $query, string $table, string $columns, string $where)
Compile an update statement with joins into SQL.
at line 1093
string
compileUpsert(Builder $query, array $values, array $uniqueBy, array $update)
Compile an "upsert" statement into SQL.
at line 1101
array
prepareBindingsForUpdate(array $bindings, array $values)
Prepare the bindings for an update statement.
at line 1115
string
compileDelete(Builder $query)
Compile a delete statement into SQL.
at line 1131
protected string
compileDeleteWithoutJoins(Builder $query, string $table, string $where)
Compile a delete statement without joins into SQL.
at line 1139
protected string
compileDeleteWithJoins(Builder $query, string $table, string $where)
Compile a delete statement with joins into SQL.
at line 1151
array
prepareBindingsForDelete(array $bindings)
Prepare the bindings for a delete statement.
at line 1161
array
compileTruncate(Builder $query)
Compile a truncate table statement into SQL.
at line 1169
protected string
compileLock(Builder $query, bool|string $value)
Compile the lock into SQL.
at line 1177
string|null
compileThreadCount()
Compile a query to get the number of open connections for a database.
at line 1185
bool
supportsSavepoints()
Determine if the grammar supports savepoints.
at line 1193
string
compileSavepoint(string $name)
Compile the SQL statement to define a savepoint.
at line 1201
string
compileSavepointRollBack(string $name)
Compile the SQL statement to execute a savepoint rollback.
at line 1209
protected string
wrapJsonBooleanSelector(string $value)
Wrap the given JSON selector for boolean values.
at line 1217
protected string
wrapJsonBooleanValue(string $value)
Wrap the given JSON boolean value.
at line 1225
protected string
concatenate(array $segments)
Concatenate an array of segments, removing empties.
at line 1235
protected string
removeLeadingBoolean(string $value)
Remove the leading boolean from a statement.
at line 1243
string
substituteBindingsIntoRawSql(string $sql, array $bindings)
Substitute the given bindings into the given raw SQL query.
at line 1286
array
getOperators()
Get the grammar specific operators.
at line 1296
array
getBitwiseOperators()
Get the grammar specific bitwise operators.