Pionia Core

Agg extends ContractBuilder
in package

Aggregate functions for the PORM library.

These methods are used to perform aggregate functions on the CDatabase.

Tags
link

They can be used in the following way:

example
$dt = Porm::from('qa_criteria')->get(Agg::gt('id', 1)); // get all records where id is greater than 1
var_dump($dt);

$dt = Porm::from('qa_criteria')->get(Agg::avg('id')); // get the average of the id column
 var_dump($dt);

Table of Contents

Properties

$aggregated  : array<string|int, mixed>

Methods

avg()  : Agg
Get the average value of a column and assing it to columnName
between()  : $this
Checks if the value of the $columnName is between the given values.
build()  : array<string|int, mixed>
builder()  : static
columnsCompare()  : static
This compares two tables in the db
div()  : Agg
divide the column value
eq()  : Agg
Equal to.
gt()  : Agg
Greater than.
gte()  : Agg
Greater than or equal to.
jsonified()  : Agg
json encode the column value and assign it to the column
like()  : Agg
Used to add a like condition to a query
lt()  : Agg
Less than.
lte()  : Agg
Less than or equal to.
max()  : Agg
Get the maximum value of a column
minus()  : Agg
subtract from the column value
neq()  : Agg
Not equal to.
notBetween()  : $this
Checks if the value of the $columnName is not between the given values.
notLike()  : Agg
Used to add a like condition to a query
now()  : Agg
Assign current timestamp to a column
of()  : Agg
multiply the column value
plus()  : Agg
add to the column value
random()  : Agg
Assign a random value to a column
regex()  : $this
Check if the value of the given column matches the given regular expression
sum()  : Agg
Get the sum of a column and assign it to columnName
uuid()  : Agg
If uuid string is passed, checks if a column is matching the given uuid otherwise generates new one and assigns it to the column given

Properties

$aggregated

private array<string|int, mixed> $aggregated = []

Methods

avg()

Get the average value of a column and assing it to columnName

public avg(string $columName, string $column) : Agg
Parameters
$columName : string
$column : string

will be the column to get the minimum value from

Return values
Agg

between()

Checks if the value of the $columnName is between the given values.

public between( $columnName, array<string|int, mixed> $values) : $this

Cool for all number formats and dates

Parameters
$columnName :
$values : array<string|int, mixed>
Tags
example
Return values
$this

build()

public build() : array<string|int, mixed>
Return values
array<string|int, mixed>

builder()

public static builder(mixed ...$args) : static
Parameters
$args : mixed
Return values
static

columnsCompare()

This compares two tables in the db

public columnsCompare(string $column, string $comparison, string $otherColumn) : static
Parameters
$column : string
$comparison : string
$otherColumn : string
Tags
example
 Agg::builder()->columnsCompare('age_restriction', '=', 'age')
throws
Exception
Return values
static

div()

divide the column value

public div(string $columnName, mixed $value) : Agg
Parameters
$columnName : string
$value : mixed
Return values
Agg

eq()

Equal to.

public eq(string $columnName, mixed $value) : Agg
Parameters
$columnName : string
$value : mixed
Return values
Agg

gt()

Greater than.

public gt(string $columnName, int $value) : Agg
Parameters
$columnName : string
$value : int
Return values
Agg

gte()

Greater than or equal to.

public gte(string $columnName, int $value) : Agg
Parameters
$columnName : string
$value : int
Return values
Agg

jsonified()

json encode the column value and assign it to the column

public jsonified(string $columnName, mixed $value) : Agg
Parameters
$columnName : string
$value : mixed
Return values
Agg

like()

Used to add a like condition to a query

public like(string $columnName, mixed $value) : Agg
Parameters
$columnName : string
$value : mixed
Return values
Agg

lt()

Less than.

public lt(string $columnName, int $value) : Agg
Parameters
$columnName : string
$value : int
Return values
Agg

lte()

Less than or equal to.

public lte(string $columnName, int $value) : Agg
Parameters
$columnName : string
$value : int
Return values
Agg

max()

Get the maximum value of a column

public max(string $columnName, string $column) : Agg
Parameters
$columnName : string

will be the alias of the result

$column : string

will be the column to get the maximum value from

Return values
Agg

minus()

subtract from the column value

public minus(string $columnName, mixed $value) : Agg
Parameters
$columnName : string
$value : mixed
Return values
Agg

neq()

Not equal to.

public neq(string $columnName, mixed $value) : Agg
Parameters
$columnName : string
$value : mixed
Return values
Agg

notBetween()

Checks if the value of the $columnName is not between the given values.

public notBetween( $columnName, array<string|int, mixed> $values) : $this

Cool for all number formats and dates too

Parameters
$columnName :
$values : array<string|int, mixed>
Tags
example
Return values
$this

notLike()

Used to add a like condition to a query

public notLike(string $columnName, string|array<string|int, mixed> $value) : Agg
Parameters
$columnName : string
$value : string|array<string|int, mixed>
Return values
Agg

now()

Assign current timestamp to a column

public now(string $columName) : Agg
Parameters
$columName : string

The column to assign the current timestamp to

Return values
Agg

of()

multiply the column value

public of(string $columnName, mixed $value) : Agg
Parameters
$columnName : string
$value : mixed
Return values
Agg

plus()

add to the column value

public plus(string $columnName, mixed $value) : Agg
Parameters
$columnName : string
$value : mixed
Return values
Agg

random()

Assign a random value to a column

public random(string $columnName) : Agg
Parameters
$columnName : string

will be the alias of the result

Return values
Agg

regex()

Check if the value of the given column matches the given regular expression

public regex( $columnName, string $regex) : $this
Parameters
$columnName :
$regex : string
Return values
$this

sum()

Get the sum of a column and assign it to columnName

public sum(string $columName, string $column) : Agg
Parameters
$columName : string

will be the alias of the result

$column : string

will be the column to get the minimum value from

Return values
Agg

uuid()

If uuid string is passed, checks if a column is matching the given uuid otherwise generates new one and assigns it to the column given

public uuid(string $columnName, string|null $uuidString) : Agg
Parameters
$columnName : string
$uuidString : string|null

optional

Return values
Agg

        
On this page

Search results