SqlField
extends SqlExpression
in package
Sql column expression
Table of Contents
Properties
- $expr : string
- The raw expression, minus the alias.
- $supportsExpansion : bool
- Whether or not pseudoconstant suffixes should be evaluated during output.
- $alias : string|null
- The SELECT alias (if null it will be calculated by getAlias)
- $dataType : string
- Data type output by this expression
- $fields : array<string|int, string>
- Field names used in this expression
Methods
- __construct() : mixed
- SqlFunction constructor.
- convert() : SqlExpression
- Converts a string to a SqlExpression object.
- getAlias() : string
- Returns the alias to use for SELECT AS.
- getDataType() : string|null
- getExpr() : string
- getFields() : array<string|int, mixed>
- Returns the field names of all sql columns that are arguments to this expression.
- getSerialize() : int|null
- Get value serialization method if any.
- getTitle() : string
- getType() : string
- Returns the name of this sql expression class.
- isType() : bool
- Checks the name of this sql expression class.
- render() : string
- Renders expression to a sql string, replacing field names with column names.
- captureExpression() : string
- Scans the beginning of a string for an expression; stops when it hits delimiter
- captureExpressions() : array<string|int, SqlExpression>
- Shifts 0 or more expressions off the argument string and returns them
- captureKeyword() : mixed|null
- Shift a keyword off the beginning of the argument string and return it.
- initialize() : mixed
- munge() : mixed
Properties
$expr
The raw expression, minus the alias.
public
string
$expr
= ''
$supportsExpansion
Whether or not pseudoconstant suffixes should be evaluated during output.
public
bool
$supportsExpansion
= TRUE
$alias
The SELECT alias (if null it will be calculated by getAlias)
protected
string|null
$alias
$dataType
Data type output by this expression
protected
static string
$dataType
$fields
Field names used in this expression
protected
array<string|int, string>
$fields
= []
Methods
__construct()
SqlFunction constructor.
public
__construct(string $expr[, string|null $alias = NULL ]) : mixed
Parameters
- $expr : string
- $alias : string|null = NULL
convert()
Converts a string to a SqlExpression object.
public
static convert(string $expression[, bool $parseAlias = FALSE ][, array<string|int, mixed> $mustBe = [] ]) : SqlExpression
E.g. the expression "SUM(foo)" would return a SqlFunctionSUM object.
Parameters
- $expression : string
- $parseAlias : bool = FALSE
- $mustBe : array<string|int, mixed> = []
Tags
Return values
SqlExpressiongetAlias()
Returns the alias to use for SELECT AS.
public
getAlias() : string
Return values
stringgetDataType()
public
static getDataType() : string|null
Return values
string|nullgetExpr()
public
getExpr() : string
Return values
stringgetFields()
Returns the field names of all sql columns that are arguments to this expression.
public
getFields() : array<string|int, mixed>
Return values
array<string|int, mixed>getSerialize()
Get value serialization method if any.
public
getSerialize() : int|null
Return values
int|nullgetTitle()
public
static getTitle() : string
Return values
stringgetType()
Returns the name of this sql expression class.
public
getType() : string
Return values
stringisType()
Checks the name of this sql expression class.
public
isType(mixed $type) : bool
Parameters
- $type : mixed
Return values
boolrender()
Renders expression to a sql string, replacing field names with column names.
public
render(Api4Query $query[, bool $includeAlias = FALSE ]) : string
Parameters
- $query : Api4Query
- $includeAlias : bool = FALSE
Return values
stringcaptureExpression()
Scans the beginning of a string for an expression; stops when it hits delimiter
protected
captureExpression(mixed $arg) : string
Parameters
- $arg : mixed
Return values
stringcaptureExpressions()
Shifts 0 or more expressions off the argument string and returns them
protected
captureExpressions(string &$arg, array<string|int, mixed> $mustBe, int $max) : array<string|int, SqlExpression>
Parameters
- $arg : string
- $mustBe : array<string|int, mixed>
- $max : int
Tags
Return values
array<string|int, SqlExpression>captureKeyword()
Shift a keyword off the beginning of the argument string and return it.
protected
captureKeyword(array<string|int, mixed> $keywords, string &$arg) : mixed|null
Parameters
- $keywords : array<string|int, mixed>
-
Whitelist of keywords
- $arg : string
Return values
mixed|nullinitialize()
protected
initialize() : mixed
munge()
private
static munge(mixed $name[, mixed $char = '_' ][, mixed $len = 63 ]) : mixed
Parameters
- $name : mixed
- $char : mixed = '_'
- $len : mixed = 63