Menu

## Agg extends ContractBuilder
in package

Agg.php : 39

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

Agg.php : 41
`private array<string|int, mixed> $aggregated = []`

### Methods

#### avg()

Agg.php : 79

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()

Agg.php : 325

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()

Agg.php : 43
`public build() : array<string|int, mixed>`

##### Return values

array<string|int, mixed>

#### builder()

ContractBuilder.php : 7
`public static builder(mixed ...$args) : static`

##### Parameters

$args : mixed

##### Return values

static

#### columnsCompare()

Agg.php : 308

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()

Agg.php : 266

divide the column value

`public div(string $columnName, mixed $value) : Agg`

##### Parameters

$columnName : string
$value : mixed

##### Return values

Agg

#### eq()

Agg.php : 188

Equal to.

`public eq(string $columnName, mixed $value) : Agg`

##### Parameters

$columnName : string
$value : mixed

##### Return values

Agg

#### gt()

Agg.php : 162

Greater than.

`public gt(string $columnName, int $value) : Agg`

##### Parameters

$columnName : string
$value : int

##### Return values

Agg

#### gte()

Agg.php : 175

Greater than or equal to.

`public gte(string $columnName, int $value) : Agg`

##### Parameters

$columnName : string
$value : int

##### Return values

Agg

#### jsonified()

Agg.php : 253

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()

Agg.php : 280

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()

Agg.php : 136

Less than.

`public lt(string $columnName, int $value) : Agg`

##### Parameters

$columnName : string
$value : int

##### Return values

Agg

#### lte()

Agg.php : 149

Less than or equal to.

`public lte(string $columnName, int $value) : Agg`

##### Parameters

$columnName : string
$value : int

##### Return values

Agg

#### max()

Agg.php : 92

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()

Agg.php : 227

subtract from the column value

`public minus(string $columnName, mixed $value) : Agg`

##### Parameters

$columnName : string
$value : mixed

##### Return values

Agg

#### neq()

Agg.php : 201

Not equal to.

`public neq(string $columnName, mixed $value) : Agg`

##### Parameters

$columnName : string
$value : mixed

##### Return values

Agg

#### notBetween()

Agg.php : 339

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()

Agg.php : 294

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()

Agg.php : 105

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()

Agg.php : 240

multiply the column value

`public of(string $columnName, mixed $value) : Agg`

##### Parameters

$columnName : string
$value : mixed

##### Return values

Agg

#### plus()

Agg.php : 214

add to the column value

`public plus(string $columnName, mixed $value) : Agg`

##### Parameters

$columnName : string
$value : mixed

##### Return values

Agg

#### random()

Agg.php : 53

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()

Agg.php : 351

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()

Agg.php : 66

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()

Agg.php : 119

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

## Search results