PostgresGrammar
class PostgresGrammar extends Grammar (View source)
Traits
| CompilesJsonPaths | |
| Macroable |
Properties
| static protected array | $macros | The registered string macros. | from Macroable |
| protected Connection | $connection | The connection used for escaping values. | from Grammar |
| protected string | $tablePrefix | The grammar table prefix. | from Grammar |
| protected string[] | $operators | All of the available clause operators. | |
| protected array | $bitwiseOperators | The grammar specific bitwise operators. | |
| protected string[] | $selectComponents | The components that make up a select clause. | from Grammar |
Methods
| static void | macro(string $name, object|callable $macro)
Register a custom macro. | from Macroable |
| static void | mixin(object $mixin, bool $replace = true)
Mix another object into the class. | from Macroable |
| static bool | hasMacro(string $name)
Checks if macro is registered. | from Macroable |
| static void | flushMacros()
Flush the existing macros. | from Macroable |
| static mixed | __callStatic(string $method, array $parameters)
Dynamically handle calls to the class. | from Macroable |
| mixed | __call(string $method, array $parameters)
Dynamically handle calls to the class. | from Macroable |
| array | wrapArray(array $values)
Wrap an array of values. | from Grammar |
| string | wrapTable(Expression|string $table)
Wrap a table in keyword identifiers. | from Grammar |
| string | wrap(Expression|string $value, bool $prefixAlias = false)
Wrap a value in keyword identifiers. | from Grammar |
| string | wrapAliasedValue(string $value, bool $prefixAlias = false)
Wrap a value that has an alias. | from Grammar |
| string | wrapSegments(array $segments)
Wrap the given value segments. | from Grammar |
| string | wrapValue(string $value)
Wrap a single string in keyword identifiers. | from Grammar |
| string | wrapJsonSelector(string $value)
Wrap the given JSON selector. | |
| bool | isJsonSelector(string $value)
Determine if the given string is a JSON selector. | from Grammar |
| string | columnize(array $columns)
Convert an array of column names into a delimited string. | from Grammar |
| string | parameterize(array $values)
Create query parameter place-holders for an array. | from Grammar |
| string | parameter(mixed $value)
Get the appropriate query parameter place-holder for a value. | from Grammar |
| string | quoteString(string|array $value)
Quote the given string literal. | from Grammar |
| string | escape(string|float|int|bool|null $value, bool $binary = false)
Escapes a value for safe SQL embedding. | from Grammar |
| bool | isExpression(mixed $value)
Determine if the given value is a raw expression. | from Grammar |
| string|int|float | getValue(Expression|string|int|float $expression)
Transforms expressions to their scalar types. | from Grammar |
| string | getDateFormat()
Get the format for database stored dates. | from Grammar |
| string | getTablePrefix()
Get the grammar's table prefix. | from Grammar |
| $this | setTablePrefix(string $prefix)
Set the grammar's table prefix. | from Grammar |
| $this | setConnection(Connection $connection)
Set the grammar's database connection. | from Grammar |
| array | wrapJsonFieldAndPath(string $column)
Split the given JSON selector into the field and the optional path and wrap them separately. | from CompilesJsonPaths |
| string | wrapJsonPath(string $value, string $delimiter = '->')
Wrap the given JSON path. | from CompilesJsonPaths |
| string | wrapJsonPathSegment(string $segment)
Wrap the given JSON path segment. | from CompilesJsonPaths |
| string | compileSelect(Builder $query)
Compile a select query into SQL. | from Grammar |
| array | compileComponents(Builder $query)
Compile the components necessary for a select clause. | from Grammar |
| string | compileAggregate(Builder $query, array $aggregate)
Compile an aggregated select clause. | from Grammar |
| string|null | compileColumns(Builder $query, array $columns)
Compile the "select *" portion of the query. | |
| string | compileFrom(Builder $query, string $table)
Compile the "from" portion of the query. | from Grammar |
| string | compileJoins(Builder $query, array $joins)
Compile the "join" portions of the query. | from Grammar |
| string | compileJoinLateral(JoinLateralClause $join, string $expression)
Compile a "lateral join" clause. | |
| string | compileWheres(Builder $query)
Compile the "where" portions of the query. | from Grammar |
| array | compileWheresToArray(Builder $query)
Get an array of all the where clauses for the query. | from Grammar |
| string | concatenateWhereClauses(Builder $query, array $sql)
Format the where clause statements into one string. | from Grammar |
| string | whereRaw(Builder $query, array $where)
Compile a raw where clause. | from Grammar |
| string | whereBasic(Builder $query, array $where)
Compile a basic where clause. | |
| string | whereBitwise(Builder $query, array $where)
Compile a bitwise operator where clause. | |
| string | whereIn(Builder $query, array $where)
Compile a "where in" clause. | from Grammar |
| string | whereNotIn(Builder $query, array $where)
Compile a "where not in" clause. | from Grammar |
| string | whereNotInRaw(Builder $query, array $where)
Compile a "where not in raw" clause. | from Grammar |
| string | whereInRaw(Builder $query, array $where)
Compile a "where in raw" clause. | from Grammar |
| string | whereNull(Builder $query, array $where)
Compile a "where null" clause. | from Grammar |
| string | whereNotNull(Builder $query, array $where)
Compile a "where not null" clause. | from Grammar |
| string | whereBetween(Builder $query, array $where)
Compile a "between" where clause. | from Grammar |
| string | whereBetweenColumns(Builder $query, array $where)
Compile a "between" where clause. | from Grammar |
| string | whereDate(Builder $query, array $where)
Compile a "where date" clause. | |
| string | whereTime(Builder $query, array $where)
Compile a "where time" clause. | |
| string | whereDay(Builder $query, array $where)
Compile a "where day" clause. | from Grammar |
| string | whereMonth(Builder $query, array $where)
Compile a "where month" clause. | from Grammar |
| string | whereYear(Builder $query, array $where)
Compile a "where year" clause. | from Grammar |
| string | dateBasedWhere(string $type, Builder $query, array $where)
Compile a date based where clause. | |
| string | whereColumn(Builder $query, array $where)
Compile a where clause comparing two columns. | from Grammar |
| string | whereNested(Builder $query, array $where)
Compile a nested where clause. | from Grammar |
| string | whereSub(Builder $query, array $where)
Compile a where condition with a sub-select. | from Grammar |
| string | whereExists(Builder $query, array $where)
Compile a where exists clause. | from Grammar |
| string | whereNotExists(Builder $query, array $where)
Compile a where exists clause. | from Grammar |
| string | whereRowValues(Builder $query, array $where)
Compile a where row values condition. | from Grammar |
| string | whereJsonBoolean(Builder $query, array $where)
Compile a "where JSON boolean" clause. | from Grammar |
| string | whereJsonContains(Builder $query, array $where)
Compile a "where JSON contains" clause. | from Grammar |
| string | compileJsonContains(string $column, string $value)
Compile a "JSON contains" statement into SQL. | |
| string | prepareBindingForJsonContains(mixed $binding)
Prepare the binding for a "JSON contains" statement. | from Grammar |
| string | whereJsonContainsKey(Builder $query, array $where)
Compile a "where JSON contains key" clause. | from Grammar |
| string | compileJsonContainsKey(string $column)
Compile a "JSON contains key" statement into SQL. | |
| string | whereJsonLength(Builder $query, array $where)
Compile a "where JSON length" clause. | from Grammar |
| string | compileJsonLength(string $column, string $operator, string $value)
Compile a "JSON length" statement into SQL. | |
| string | compileJsonValueCast(string $value)
Compile a "JSON value cast" statement into SQL. | from Grammar |
| string | whereFullText(Builder $query, array $where)
Compile a "where fulltext" clause. | |
| string | whereExpression(Builder $query, array $where)
Compile a clause based on an expression. | from Grammar |
| string | compileGroups(Builder $query, array $groups)
Compile the "group by" portions of the query. | from Grammar |
| string | compileHavings(Builder $query)
Compile the "having" portions of the query. | from Grammar |
| string | compileHaving(array $having)
Compile a single having clause. | |
| string | compileBasicHaving(array $having)
Compile a basic having clause. | from Grammar |
| string | compileHavingBetween(array $having)
Compile a "between" having clause. | from Grammar |
| string | compileHavingNull(array $having)
Compile a having null clause. | from Grammar |
| string | compileHavingNotNull(array $having)
Compile a having not null clause. | from Grammar |
| string | compileHavingBit(array $having)
Compile a having clause involving a bit operator. | from Grammar |
| string | compileHavingExpression(array $having)
Compile a having clause involving an expression. | from Grammar |
| string | compileNestedHavings(array $having)
Compile a nested having clause. | from Grammar |
| string | compileOrders(Builder $query, array $orders)
Compile the "order by" portions of the query. | from Grammar |
| array | compileOrdersToArray(Builder $query, array $orders)
Compile the query orders to an array. | from Grammar |
| string | compileRandom(string|int $seed)
Compile the random statement into SQL. | from Grammar |
| string | compileLimit(Builder $query, int $limit)
Compile the "limit" portions of the query. | from Grammar |
| string | compileOffset(Builder $query, int $offset)
Compile the "offset" portions of the query. | from Grammar |
| string | compileUnions(Builder $query)
Compile the "union" queries attached to the main query. | from Grammar |
| string | compileUnion(array $union)
Compile a single union statement. | from Grammar |
| string | wrapUnion(string $sql)
Wrap a union subquery in parentheses. | from Grammar |
| string | compileUnionAggregate(Builder $query)
Compile a union aggregate query into SQL. | from Grammar |
| string | compileExists(Builder $query)
Compile an exists statement into SQL. | from Grammar |
| string | compileInsert(Builder $query, array $values)
Compile an insert statement into SQL. | from Grammar |
| string | compileInsertOrIgnore(Builder $query, array $values)
Compile an insert ignore statement into SQL. | |
| string | compileInsertGetId(Builder $query, array $values, string $sequence)
Compile an insert and get ID statement into SQL. | |
| string | compileInsertUsing(Builder $query, array $columns, string $sql)
Compile an insert statement using a subquery into SQL. | from Grammar |
| string | compileInsertOrIgnoreUsing(Builder $query, array $columns, string $sql)
Compile an insert ignore statement using a subquery into SQL. | |
| string | compileUpdate(Builder $query, array $values)
Compile an update statement into SQL. | |
| string | compileUpdateColumns(Builder $query, array $values)
Compile the columns for an update statement. | |
| string | compileUpdateWithoutJoins(Builder $query, string $table, string $columns, string $where)
Compile an update statement without joins into SQL. | from Grammar |
| string | compileUpdateWithJoins(Builder $query, string $table, string $columns, string $where)
Compile an update statement with joins into SQL. | from Grammar |
| string | compileUpsert(Builder $query, array $values, array $uniqueBy, array $update)
Compile an "upsert" statement into SQL. | |
| array | prepareBindingsForUpdate(array $bindings, array $values)
Prepare the bindings for an update statement. | |
| string | compileDelete(Builder $query)
Compile a delete statement into SQL. | |
| string | compileDeleteWithoutJoins(Builder $query, string $table, string $where)
Compile a delete statement without joins into SQL. | from Grammar |
| string | compileDeleteWithJoins(Builder $query, string $table, string $where)
Compile a delete statement with joins into SQL. | from Grammar |
| array | prepareBindingsForDelete(array $bindings)
Prepare the bindings for a delete statement. | from Grammar |
| array | compileTruncate(Builder $query)
Compile a truncate table statement into SQL. | |
| string | compileLock(Builder $query, bool|string $value)
Compile the lock into SQL. | |
| bool | supportsSavepoints()
Determine if the grammar supports savepoints. | from Grammar |
| string | compileSavepoint(string $name)
Compile the SQL statement to define a savepoint. | from Grammar |
| string | compileSavepointRollBack(string $name)
Compile the SQL statement to execute a savepoint rollback. | from Grammar |
| string | wrapJsonBooleanSelector(string $value)
Wrap the given JSON selector for boolean values. | |
| string | wrapJsonBooleanValue(string $value)
Wrap the given JSON boolean value. | |
| string | concatenate(array $segments)
Concatenate an array of segments, removing empties. | from Grammar |
| string | removeLeadingBoolean(string $value)
Remove the leading boolean from a statement. | from Grammar |
| string | substituteBindingsIntoRawSql(string $sql, array $bindings)
Substitute the given bindings into the given raw SQL query. | |
| array | getOperators()
Get the grammar specific operators. | from Grammar |
| array | getBitwiseOperators()
Get the grammar specific bitwise operators. | from Grammar |
| array | validFullTextLanguages()
Get an array of valid full text languages. | |
| string | compileHavingBitwise(array $having)
Compile a having clause involving a bitwise operator. | |
| string | compileJsonUpdateColumn(string $key, mixed $value)
Prepares a JSON column being updated using the JSONB_SET function. | |
| string | compileUpdateFrom(Builder $query, array $values)
Compile an update from statement into SQL. | |
| string | compileUpdateWheres(Builder $query)
Compile the additional where clauses for updates with joins. | |
| string | compileUpdateJoinWheres(Builder $query)
Compile the "join" clause where clauses for an update. | |
| array | prepareBindingsForUpdateFrom(array $bindings, array $values)
Prepare the bindings for an update statement. | |
| string | compileUpdateWithJoinsOrLimit(Builder $query, array $values)
Compile an update statement with joins or limit into SQL. | |
| string | compileDeleteWithJoinsOrLimit(Builder $query)
Compile a delete statement with joins or limit into SQL. | |
| array | wrapJsonPathAttributes(array $path)
Wrap the attributes of the given JSON path. | |
| array | parseJsonPathArrayKeys(string $attribute)
Parse the given JSON path attribute for array keys. |
Details
static void macro(string $name, object|callable $macro)
Register a custom macro.
static void mixin(object $mixin, bool $replace = true)
Mix another object into the class.
static bool hasMacro(string $name)
Checks if macro is registered.
static void flushMacros()
Flush the existing macros.
static mixed __callStatic(string $method, array $parameters)
Dynamically handle calls to the class.
mixed __call(string $method, array $parameters)
Dynamically handle calls to the class.
array wrapArray(array $values)
Wrap an array of values.
string wrapTable(Expression|string $table)
Wrap a table in keyword identifiers.
string wrap(Expression|string $value, bool $prefixAlias = false)
Wrap a value in keyword identifiers.
protected string wrapAliasedValue(string $value, bool $prefixAlias = false)
Wrap a value that has an alias.
protected string wrapSegments(array $segments)
Wrap the given value segments.
protected string wrapValue(string $value)
Wrap a single string in keyword identifiers.
protected string wrapJsonSelector(string $value)
Wrap the given JSON selector.
protected bool isJsonSelector(string $value)
Determine if the given string is a JSON selector.
string columnize(array $columns)
Convert an array of column names into a delimited string.
string parameterize(array $values)
Create query parameter place-holders for an array.
string parameter(mixed $value)
Get the appropriate query parameter place-holder for a value.
string quoteString(string|array $value)
Quote the given string literal.
string escape(string|float|int|bool|null $value, bool $binary = false)
Escapes a value for safe SQL embedding.
bool isExpression(mixed $value)
Determine if the given value is a raw expression.
string|int|float getValue(Expression|string|int|float $expression)
Transforms expressions to their scalar types.
string getDateFormat()
Get the format for database stored dates.
string getTablePrefix()
Get the grammar's table prefix.
$this setTablePrefix(string $prefix)
Set the grammar's table prefix.
$this setConnection(Connection $connection)
Set the grammar's database connection.
protected array wrapJsonFieldAndPath(string $column)
Split the given JSON selector into the field and the optional path and wrap them separately.
protected string wrapJsonPath(string $value, string $delimiter = '->')
Wrap the given JSON path.
protected string wrapJsonPathSegment(string $segment)
Wrap the given JSON path segment.
string compileSelect(Builder $query)
Compile a select query into SQL.
protected array compileComponents(Builder $query)
Compile the components necessary for a select clause.
protected string compileAggregate(Builder $query, array $aggregate)
Compile an aggregated select clause.
protected string|null compileColumns(Builder $query, array $columns)
Compile the "select *" portion of the query.
protected string compileFrom(Builder $query, string $table)
Compile the "from" portion of the query.
protected string compileJoins(Builder $query, array $joins)
Compile the "join" portions of the query.
string compileJoinLateral(JoinLateralClause $join, string $expression)
Compile a "lateral join" clause.
string compileWheres(Builder $query)
Compile the "where" portions of the query.
protected array compileWheresToArray(Builder $query)
Get an array of all the where clauses for the query.
protected string concatenateWhereClauses(Builder $query, array $sql)
Format the where clause statements into one string.
protected string whereRaw(Builder $query, array $where)
Compile a raw where clause.
protected string whereBasic(Builder $query, array $where)
Compile a basic where clause.
protected string whereBitwise(Builder $query, array $where)
Compile a bitwise operator where clause.
protected string whereIn(Builder $query, array $where)
Compile a "where in" clause.
protected string whereNotIn(Builder $query, array $where)
Compile a "where not in" clause.
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.
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.
protected string whereNull(Builder $query, array $where)
Compile a "where null" clause.
protected string whereNotNull(Builder $query, array $where)
Compile a "where not null" clause.
protected string whereBetween(Builder $query, array $where)
Compile a "between" where clause.
protected string whereBetweenColumns(Builder $query, array $where)
Compile a "between" where clause.
protected string whereDate(Builder $query, array $where)
Compile a "where date" clause.
protected string whereTime(Builder $query, array $where)
Compile a "where time" clause.
protected string whereDay(Builder $query, array $where)
Compile a "where day" clause.
protected string whereMonth(Builder $query, array $where)
Compile a "where month" clause.
protected string whereYear(Builder $query, array $where)
Compile a "where year" clause.
protected string dateBasedWhere(string $type, Builder $query, array $where)
Compile a date based where clause.
protected string whereColumn(Builder $query, array $where)
Compile a where clause comparing two columns.
protected string whereNested(Builder $query, array $where)
Compile a nested where clause.
protected string whereSub(Builder $query, array $where)
Compile a where condition with a sub-select.
protected string whereExists(Builder $query, array $where)
Compile a where exists clause.
protected string whereNotExists(Builder $query, array $where)
Compile a where exists clause.
protected string whereRowValues(Builder $query, array $where)
Compile a where row values condition.
protected string whereJsonBoolean(Builder $query, array $where)
Compile a "where JSON boolean" clause.
protected string whereJsonContains(Builder $query, array $where)
Compile a "where JSON contains" clause.
protected string compileJsonContains(string $column, string $value)
Compile a "JSON contains" statement into SQL.
string prepareBindingForJsonContains(mixed $binding)
Prepare the binding for a "JSON contains" statement.
protected string whereJsonContainsKey(Builder $query, array $where)
Compile a "where JSON contains key" clause.
protected string compileJsonContainsKey(string $column)
Compile a "JSON contains key" statement into SQL.
protected string whereJsonLength(Builder $query, array $where)
Compile a "where JSON length" clause.
protected string compileJsonLength(string $column, string $operator, string $value)
Compile a "JSON length" statement into SQL.
string compileJsonValueCast(string $value)
Compile a "JSON value cast" statement into SQL.
string whereFullText(Builder $query, array $where)
Compile a "where fulltext" clause.
string whereExpression(Builder $query, array $where)
Compile a clause based on an expression.
protected string compileGroups(Builder $query, array $groups)
Compile the "group by" portions of the query.
protected string compileHavings(Builder $query)
Compile the "having" portions of the query.
protected string compileHaving(array $having)
Compile a single having clause.
protected string compileBasicHaving(array $having)
Compile a basic having clause.
protected string compileHavingBetween(array $having)
Compile a "between" having clause.
protected string compileHavingNull(array $having)
Compile a having null clause.
protected string compileHavingNotNull(array $having)
Compile a having not null clause.
protected string compileHavingBit(array $having)
Compile a having clause involving a bit operator.
protected string compileHavingExpression(array $having)
Compile a having clause involving an expression.
protected string compileNestedHavings(array $having)
Compile a nested having clause.
protected string compileOrders(Builder $query, array $orders)
Compile the "order by" portions of the query.
protected array compileOrdersToArray(Builder $query, array $orders)
Compile the query orders to an array.
string compileRandom(string|int $seed)
Compile the random statement into SQL.
protected string compileLimit(Builder $query, int $limit)
Compile the "limit" portions of the query.
protected string compileOffset(Builder $query, int $offset)
Compile the "offset" portions of the query.
protected string compileUnions(Builder $query)
Compile the "union" queries attached to the main query.
protected string compileUnion(array $union)
Compile a single union statement.
protected string wrapUnion(string $sql)
Wrap a union subquery in parentheses.
protected string compileUnionAggregate(Builder $query)
Compile a union aggregate query into SQL.
string compileExists(Builder $query)
Compile an exists statement into SQL.
string compileInsert(Builder $query, array $values)
Compile an insert statement into SQL.
string compileInsertOrIgnore(Builder $query, array $values)
Compile an insert ignore statement into SQL.
string compileInsertGetId(Builder $query, array $values, string $sequence)
Compile an insert and get ID statement into SQL.
string compileInsertUsing(Builder $query, array $columns, string $sql)
Compile an insert statement using a subquery into SQL.
string compileInsertOrIgnoreUsing(Builder $query, array $columns, string $sql)
Compile an insert ignore statement using a subquery into SQL.
string compileUpdate(Builder $query, array $values)
Compile an update statement into SQL.
protected string compileUpdateColumns(Builder $query, array $values)
Compile the columns for an update statement.
protected string compileUpdateWithoutJoins(Builder $query, string $table, string $columns, string $where)
Compile an update statement without joins into SQL.
protected string compileUpdateWithJoins(Builder $query, string $table, string $columns, string $where)
Compile an update statement with joins into SQL.
string compileUpsert(Builder $query, array $values, array $uniqueBy, array $update)
Compile an "upsert" statement into SQL.
array prepareBindingsForUpdate(array $bindings, array $values)
Prepare the bindings for an update statement.
string compileDelete(Builder $query)
Compile a delete statement into SQL.
protected string compileDeleteWithoutJoins(Builder $query, string $table, string $where)
Compile a delete statement without joins into SQL.
protected string compileDeleteWithJoins(Builder $query, string $table, string $where)
Compile a delete statement with joins into SQL.
array prepareBindingsForDelete(array $bindings)
Prepare the bindings for a delete statement.
array compileTruncate(Builder $query)
Compile a truncate table statement into SQL.
protected string compileLock(Builder $query, bool|string $value)
Compile the lock into SQL.
bool supportsSavepoints()
Determine if the grammar supports savepoints.
string compileSavepoint(string $name)
Compile the SQL statement to define a savepoint.
string compileSavepointRollBack(string $name)
Compile the SQL statement to execute a savepoint rollback.
protected string wrapJsonBooleanSelector(string $value)
Wrap the given JSON selector for boolean values.
protected string wrapJsonBooleanValue(string $value)
Wrap the given JSON boolean value.
protected string concatenate(array $segments)
Concatenate an array of segments, removing empties.
protected string removeLeadingBoolean(string $value)
Remove the leading boolean from a statement.
string substituteBindingsIntoRawSql(string $sql, array $bindings)
Substitute the given bindings into the given raw SQL query.
array getOperators()
Get the grammar specific operators.
array getBitwiseOperators()
Get the grammar specific bitwise operators.
protected array validFullTextLanguages()
Get an array of valid full text languages.
protected string compileHavingBitwise(array $having)
Compile a having clause involving a bitwise operator.
protected string compileJsonUpdateColumn(string $key, mixed $value)
Prepares a JSON column being updated using the JSONB_SET function.
string compileUpdateFrom(Builder $query, array $values)
Compile an update from statement into SQL.
protected string compileUpdateWheres(Builder $query)
Compile the additional where clauses for updates with joins.
protected string compileUpdateJoinWheres(Builder $query)
Compile the "join" clause where clauses for an update.
array prepareBindingsForUpdateFrom(array $bindings, array $values)
Prepare the bindings for an update statement.
protected string compileUpdateWithJoinsOrLimit(Builder $query, array $values)
Compile an update statement with joins or limit into SQL.
protected string compileDeleteWithJoinsOrLimit(Builder $query)
Compile a delete statement with joins or limit into SQL.
protected array wrapJsonPathAttributes(array $path)
Wrap the attributes of the given JSON path.
protected array parseJsonPathArrayKeys(string $attribute)
Parse the given JSON path attribute for array keys.
© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/10.x/Illuminate/Database/Query/Grammars/PostgresGrammar.html