Pionia Core

Builder extends ContractBuilder
in package
Uses AggregateTrait, ParseTrait, FilterTrait

Table of Contents

Properties

$columns  : mixed|string
$database  : Piql
$preventLimit  : bool
$table  : string
$where  : array<string|int, mixed>

Methods

__construct()  : mixed
all()  : array<string|int, mixed>|null
Returns all items from the CDatabase. If a callback is passed, it will be called on each item in the resultset
avg()  : string|null
build()  : mixed
builder()  : static
count()  : int|null
delete()  : PDOStatement|null
first()  : object|null
Same as get() but returns the first item of the resultset
get()  : object|null
Returns one item from the CDatabase
group()  : mixed
having()  : $this
Adds a 'having' clause to the query
limit()  : static
match()  : static
max()  : string|null
min()  : string|null
orderBy()  : $this
Orders the query by certain value.
startAt()  : static
sum()  : string|null
where()  : static
runGet()  : mixed
runSelect()  : array<string|int, mixed>|null

Properties

$columns

private mixed|string $columns = "*"

$preventLimit

private bool $preventLimit = false

$where

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

Methods

__construct()

public __construct(mixed $table, Piql $database[, mixed $columns = "*" ][, mixed $where = [] ]) : mixed
Parameters
$table : mixed
$database : Piql
$columns : mixed = "*"
$where : mixed = []

all()

Returns all items from the CDatabase. If a callback is passed, it will be called on each item in the resultset

public all([callable|null $callback = null ]) : array<string|int, mixed>|null
Parameters
$callback : callable|null = null

This is the receiver for the current resultset

Tags
example
// Assignment method
$row = Table::from('user')
    ->filter(['last_name' => 'Ezra'])
   ->all();

// Callback method- this is little bit faster than the assignment method
Table::from('user')
   ->filter(['last_name' => 'Ezra'])
  ->all(function($row) {
     echo $row->first_name;
 });
Return values
array<string|int, mixed>|null

avg()

public avg(string $column, array<string|int, mixed>|null $where) : string|null
Parameters
$column : string
$where : array<string|int, mixed>|null
Tags
see
Porm::avg()
Return values
string|null

builder()

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

count()

public count([string|null $column = null ][, array<string|int, mixed>|null $where = null ]) : int|null
Parameters
$column : string|null = null
$where : array<string|int, mixed>|null = null
Tags
see
Porm::count()
Return values
int|null

delete()

public delete(int|array<string|int, mixed>|string $where[, string|null $idField = 'id' ]) : PDOStatement|null
Parameters
$where : int|array<string|int, mixed>|string
$idField : string|null = 'id'
Tags
example
  $res1 = Porm::from('users')->delete(1); // deletes a user with id 1
  $res2 = Porm::from('users')->delete(['name' => 'John']); // deletes a user with name John
Return values
PDOStatement|null

first()

Same as get() but returns the first item of the resultset

public first() : object|null
Return values
object|null

get()

Returns one item from the CDatabase

public get([array<string|int, mixed>|int|null $where = null ]) : object|null
Parameters
$where : array<string|int, mixed>|int|null = null
Tags
example
$row = Table::from('user')
     ->filter(['last_name' => 'Ezra'])
     ->get();
Return values
object|null

group()

public group(string|array<string|int, mixed> $group) : mixed
Parameters
$group : string|array<string|int, mixed>

having()

Adds a 'having' clause to the query

public having(string $column, mixed $value[, string|null $needle = null ]) : $this
Parameters
$column : string
$value : mixed
$needle : string|null = null

can be >, <, !,>=, <=. >< and <> are available for datetime

Return values
$this

limit()

public limit(int $limit) : static
Parameters
$limit : int
Tags
throws
Exception
Return values
static

match()

public match(mixed $columns, mixed $keyword[, mixed $mode = 'natural' ]) : static
Parameters
$columns : mixed
$keyword : mixed
$mode : mixed = 'natural'
Return values
static

max()

public max(string $column, array<string|int, mixed>|null $where) : string|null
Parameters
$column : string
$where : array<string|int, mixed>|null
Tags
see
Porm::max()
Return values
string|null

min()

public min(string $column, array<string|int, mixed>|null $where) : string|null
Parameters
$column : string
$where : array<string|int, mixed>|null
Tags
see
Porm::min()
Return values
string|null

orderBy()

Orders the query by certain value.

public orderBy(string|array<string|int, mixed> $value) : $this
Parameters
$value : string|array<string|int, mixed>
Tags
example
// single column
->filter()
->orderBy("name")

// multiple Order items
->filter()
->orderBy(['name' => 'DESC', 'age' => 'ASC'])
Return values
$this

startAt()

public startAt([int $startPoint = 0 ]) : static
Parameters
$startPoint : int = 0
Return values
static

sum()

public sum(string $column, array<string|int, mixed>|null $where) : string|null
Parameters
$column : string
$where : array<string|int, mixed>|null
Tags
see
Porm::sum()
Return values
string|null

where()

public where(array<string|int, mixed> $where) : static
Parameters
$where : array<string|int, mixed>
Return values
static

runSelect()

private runSelect(callable|null $callback) : array<string|int, mixed>|null
Parameters
$callback : callable|null
Return values
array<string|int, mixed>|null

        
On this page

Search results