A CASE expression, with or without a subject expression.
If a subject is used, WHEN relies on equating the subject's evaluation to a literal value. This is also known as a "simple case", and is not null-safe. If you are choosing between known states, this may be the use-case for you.
Otherwise WHEN relies on arbitrary predication. This is also known as a "searched case", and may be constructed in a null-safe manner. If you are choosing amongst complex states, this may be the use-case for you.
With a subject (simple case):
CASE subject
WHEN value THEN value
...
END
Without a subject (searched case):
CASE
WHEN predicate THEN value
...
END
|
| | __construct (DB $db, string $subject=null, array $values=[]) |
| |
| string | __toString () |
| |
| $this | else ($else) |
| |
| $this | when ($expression, $then) |
| | Quotes and sets a conditional value. More...
|
| |
| $this | whenValues (array $values) |
| | Quotes and sets multiple conditional values for the subject. More...
|
| |
| | __construct (DB $db, string $expression) |
| |
| Value | coalesce (array $values) |
| | COALESCE($this, ...$values) More...
|
| |
| Num | avg () |
| | AVG($this) More...
|
| |
| Num | avgDistinct () |
| | AVG(DISTINCT $this) More...
|
| |
| Num | count () |
| | COUNT($this) More...
|
| |
| Num | countDistinct () |
| | COUNT(DISTINCT $this) More...
|
| |
| Str | groupConcat (string $delimiter=',') |
| | GROUP_CONCAT($this) using a delimiter. More...
|
| |
| Num | max () |
| | MAX($this) More...
|
| |
| Num | min () |
| | MIN($this) More...
|
| |
| Num | sum () |
| | SUM($this) More...
|
| |
| Num | sumDistinct () |
| | SUM(DISTINCT $this) More...
|
| |
| Predicate | is ($arg) |
| | Null-safe type-strict equality. More...
|
| |
| Predicate | isBetween ($min, $max) |
| | $this BETWEEN $min AND $max (inclusive) More...
|
| |
| Predicate | isEqual ($arg) |
| | See Predicate::match(). More...
|
| |
| Predicate | isFalse () |
| | $this IS FALSE More...
|
| |
| Predicate | isGt ($arg) |
| | $this > $arg, or driver-appropriate $this > ALL (SELECT ...) More...
|
| |
| Predicate | isGtAny (Select $select) |
| | Driver-appropriate $this > ANY (SELECT ...) More...
|
| |
| Predicate | isGte ($arg) |
| | $this >= $arg, or driver-appropriate $this >= ALL (SELECT ...) More...
|
| |
| Predicate | isGteAny (Select $select) |
| | Driver-appropriate $this >= ANY (SELECT ...) More...
|
| |
| Predicate | isLike (string $pattern) |
| | $this LIKE $pattern More...
|
| |
| Predicate | isLt ($arg) |
| | $this < $arg, or driver-appropriate $this < ALL (SELECT ...) More...
|
| |
| Predicate | isLtAny (Select $select) |
| | Driver-appropriate $this < ANY (SELECT ...) More...
|
| |
| Predicate | isLte ($arg) |
| | $this <= $arg, or driver-appropriate $this <= ALL (SELECT ...) More...
|
| |
| Predicate | isLteAny (Select $select) |
| | Driver-appropriate $this <= ANY (SELECT ...) More...
|
| |
| Predicate | isNot ($arg) |
| | Null-safe type-strict inequality. More...
|
| |
| Predicate | isNotBetween ($min, $max) |
| | $this NOT BETWEEN $min AND $max (inclusive) More...
|
| |
| Predicate | isNotEqual ($arg) |
| | $this <> $arg or $this NOT IN ($arg) More...
|
| |
| Predicate | isNotLike (string $pattern) |
| | $this NOT LIKE $pattern More...
|
| |
| Predicate | isNotNull () |
| | $this IS NOT NULL More...
|
| |
| Predicate | isNotRegExp (string $pattern) |
| | $this NOT REGEXP $pattern More...
|
| |
| Predicate | isNull () |
| | $this IS NULL More...
|
| |
| Predicate | isRegExp (string $pattern) |
| | $this REGEXP $pattern More...
|
| |
| Branch | switch (array $values=[]) |
| | CASE $this ... More...
|
| |
| DateTime | toDateTime () |
| | Interpret the expression as a datetime. More...
|
| |
| Num | toFloat () |
| | Casts the expression as a floating point number. More...
|
| |
| Num | toInt () |
| | Casts the expression as a signed integer. More...
|
| |
| Str | toStr () |
| | Casts the expression as a character string. More...
|
| |