Interface Yiisoft\Db\Query\QueryFunctionsInterface
| Implemented by | Yiisoft\Db\Query\QueryInterface |
|---|
A query function is a function that's called in a query to perform operation on the data selected or updated.
Examples of query functions might include {@see \Yiisoft\Db\Query\count()}, {@see \Yiisoft\Db\Query\sum()}, {@see \Yiisoft\Db\Query\average()}, and {@see \Yiisoft\Db\Query\max()}.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| average() | Returns the average of the specified column values. | Yiisoft\Db\Query\QueryFunctionsInterface |
| count() | Returns the number of records. | Yiisoft\Db\Query\QueryFunctionsInterface |
| max() | Returns the maximum of the specified column values. | Yiisoft\Db\Query\QueryFunctionsInterface |
| min() | Returns the minimum of the specified column values. | Yiisoft\Db\Query\QueryFunctionsInterface |
| sum() | Returns the sum of the specified column values. | Yiisoft\Db\Query\QueryFunctionsInterface |
Method Details
Returns the average of the specified column values.
| public abstract float|integer|string|null average ( string $sql ) | ||
| $sql | string |
The column name or expression. |
| return | float|integer|string|null |
The average of the specified column values. Note: Make sure you quote column names in the expression. |
|---|---|---|
| throws | Throwable | |
public function average(string $sql): int|float|string|null;
Returns the number of records.
Note: Make sure you quote column names in the expression.
| public abstract integer|string count ( string $sql = '*' ) | ||
| $sql | string |
The |
| return | integer|string |
Number of records. The result will be a string when value is higher than {@see \Yiisoft\Db\Query\PHP_INT_MAX}. |
|---|---|---|
| throws | Yiisoft\Db\Exception\InvalidConfigException | |
| throws | Throwable | |
| throws | Yiisoft\Db\Exception\Exception | |
public function count(string $sql = '*'): int|string;
Returns the maximum of the specified column values.
| public abstract float|integer|string|null max ( string $sql ) | ||
| $sql | string |
The column name or expression. |
| return | float|integer|string|null |
The maximum of the specified column values. Note: Make sure you quote column names in the expression. |
|---|---|---|
| throws | Yiisoft\Db\Exception\InvalidConfigException | |
| throws | Throwable | |
| throws | Yiisoft\Db\Exception\Exception | |
public function max(string $sql): int|float|string|null;
Returns the minimum of the specified column values.
| public abstract float|integer|string|null min ( string $sql ) | ||
| $sql | string |
The column name or expression. |
| return | float|integer|string|null |
The minimum of the specified column values. Note: Make sure you quote column names in the expression. |
|---|---|---|
| throws | Yiisoft\Db\Exception\InvalidConfigException | |
| throws | Throwable | |
| throws | Yiisoft\Db\Exception\Exception | |
public function min(string $sql): int|float|string|null;
Returns the sum of the specified column values.
| public abstract float|integer|string|null sum ( string $sql ) | ||
| $sql | string |
The column name or expression. |
| return | float|integer|string|null |
The sum of the specified column values. Note: Make sure you quote column names in the expression. |
|---|---|---|
| throws | Yiisoft\Db\Exception\InvalidConfigException | |
| throws | Throwable | |
| throws | Yiisoft\Db\Exception\Exception | |
public function sum(string $sql): int|float|string|null;
Signup or Login in order to comment.