abstract class Grammar

Traits

Properties

static protected array $macros

The registered string macros.

from  Macroable
protected Connection $connection

The connection used for escaping values.

Methods

static void
macro(string $name, callable|object $macro)

Register a custom macro.

static void
mixin(object $mixin, bool $replace = true)

Mix another object into the class.

static bool
hasMacro(string $name)

Check 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.

__construct(Connection $connection)

Create a new grammar instance.

array
wrapArray(array $values)

Wrap an array of values.

string
wrapTable(Expression|string $table, string|null $prefix = null)

Wrap a table in keyword identifiers.

string|int|float
wrap(Expression|string $value)

Wrap a value in keyword identifiers.

string
wrapAliasedValue(string $value)

Wrap a value that has an alias.

string
wrapAliasedTable(string $value, string|null $prefix = null)

Wrap a table that has an alias.

string
wrapSegments(array $segments)

Wrap the given value segments.

string
wrapValue(string $value)

Wrap a single string in keyword identifiers.

string
wrapJsonSelector(string $value)

Wrap the given JSON selector.

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|int|float
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.

static void
flushState()

Flush all static state.

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.

Parameters

string $name
callable|object $macro

Return Value

void

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.

Parameters

object $mixin
bool $replace

Return Value

void

Exceptions

ReflectionException

in Macroable at line 57
static bool hasMacro(string $name)

Check if macro is registered.

Parameters

string $name

Return Value

bool

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.

Return Value

void

in Macroable at line 78
static mixed __callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

in Macroable at line 103
mixed __call(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

at line 24
__construct(Connection $connection)

Create a new grammar instance.

Parameters

Connection $connection

at line 35
array wrapArray(array $values)

Wrap an array of values.

Parameters

array $values

Return Value

array

at line 43
string wrapTable(Expression|string $table, string|null $prefix = null)

Wrap a table in keyword identifiers.

Parameters

Expression|string $table
string|null $prefix

Return Value

string

at line 75
string|int|float wrap(Expression|string $value)

Wrap a value in keyword identifiers.

Parameters

Expression|string $value

Return Value

string|int|float

at line 101
protected string wrapAliasedValue(string $value)

Wrap a value that has an alias.

Parameters

string $value

Return Value

string

at line 111
protected string wrapAliasedTable(string $value, string|null $prefix = null)

Wrap a table that has an alias.

Parameters

string $value
string|null $prefix

Return Value

string

at line 125
protected string wrapSegments(array $segments)

Wrap the given value segments.

Parameters

array $segments

Return Value

string

at line 137
protected string wrapValue(string $value)

Wrap a single string in keyword identifiers.

Parameters

string $value

Return Value

string

at line 151
protected string wrapJsonSelector(string $value)

Wrap the given JSON selector.

Parameters

string $value

Return Value

string

Exceptions

RuntimeException

at line 159
protected bool isJsonSelector(string $value)

Determine if the given string is a JSON selector.

Parameters

string $value

Return Value

bool

at line 169
string columnize(array $columns)

Convert an array of column names into a delimited string.

Parameters

array $columns

Return Value

string

at line 177
string parameterize(array $values)

Create query parameter place-holders for an array.

Parameters

array $values

Return Value

string

at line 185
string|int|float parameter(mixed $value)

Get the appropriate query parameter place-holder for a value.

Parameters

mixed $value

Return Value

string|int|float

at line 195
string quoteString(string|array $value)

Quote the given string literal.

Parameters

string|array $value

Return Value

string

at line 207
string escape(string|float|int|bool|null $value, bool $binary = false)

Escapes a value for safe SQL embedding.

Parameters

string|float|int|bool|null $value
bool $binary

Return Value

string

at line 215
bool isExpression(mixed $value)

Determine if the given value is a raw expression.

Parameters

mixed $value

Return Value

bool

at line 223
string|int|float getValue(Expression|string|int|float $expression)

Transforms expressions to their scalar types.

Parameters

Expression|string|int|float $expression

Return Value

string|int|float

at line 235
string getDateFormat()

Get the format for database stored dates.

Return Value

string

at line 246
static void flushState()

Flush all static state.

Return Value

void