SqlEquation
extends SqlExpression
in package
Numeric sql expression
Table of Contents
Properties
- $arithmeticOperators : array<string|int, string>
- $comparisonOperators : array<string|int, string>
- $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)
- $args : array<string|int, mixed>
- $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.
- formatOutputValue() : mixed
- Change $dataType according to operator used in equation
- getAlias() : string
- Returns the alias to use for SELECT AS.
- getArgs() : array<string|int, mixed>
- Get the arguments and operators passed to this sql expression.
- 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
- Render the expression for insertion into the sql query
- 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.
- getOperatorType() : string|null
- Check if an item is an operator and if so what category it belongs to
- initialize() : mixed
- munge() : mixed
Properties
$arithmeticOperators
public
static array<string|int, string>
$arithmeticOperators
= ['+', '-', '*', '/', '%']
$comparisonOperators
public
static array<string|int, string>
$comparisonOperators
= ['<=', '>=', '<', '>', '=', '!=', '<=>', 'IS NOT', 'IS', 'BETWEEN', 'AND']
$expr
The raw expression, minus the alias.
public
string
$expr
= ''
$supportsExpansion
Whether or not pseudoconstant suffixes should be evaluated during output.
public
bool
$supportsExpansion
= FALSE
Tags
$alias
The SELECT alias (if null it will be calculated by getAlias)
protected
string|null
$alias
$args
protected
array<string|int, mixed>
$args
= []
$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
SqlExpressionformatOutputValue()
Change $dataType according to operator used in equation
public
formatOutputValue(string|null &$dataType, array<string|int, mixed> &$values) : mixed
Parameters
- $dataType : string|null
- $values : array<string|int, mixed>
Tags
getAlias()
Returns the alias to use for SELECT AS.
public
getAlias() : string
Return values
stringgetArgs()
Get the arguments and operators passed to this sql expression.
public
getArgs() : array<string|int, mixed>
For each item in the returned array, if it's an array, it's a value; if it's a string, it's an operator.
Return values
array<string|int, mixed>getDataType()
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()
Render the expression for insertion into the sql query
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|nullgetOperatorType()
Check if an item is an operator and if so what category it belongs to
protected
getOperatorType(mixed $item) : string|null
Parameters
- $item : mixed
Return values
string|nullinitialize()
protected
initialize() : mixed
munge()
private
static munge(mixed $name[, mixed $char = '_' ][, mixed $len = 63 ]) : mixed
Parameters
- $name : mixed
- $char : mixed = '_'
- $len : mixed = 63