class Builder extends QueryBuilder (View source)

Properties

protected string $table

The table name

from  QueryBuilder
protected string $select

Select statement collector

from  QueryBuilder
protected string $where

Where statement collector

from  QueryBuilder
protected array $where_data_binding

The data binding information

from  QueryBuilder
protected string $join

Join statement collector

from  QueryBuilder
protected string $limit

Limit statement collector

from  QueryBuilder
protected string $group

Group statement collector

from  QueryBuilder
protected string $having

Having statement collector

from  QueryBuilder
protected string $order

Order By statement collector

from  QueryBuilder
protected string $as

Define the table as

from  QueryBuilder
protected PDO $connection

The PDO instance

from  QueryBuilder
protected bool $first

Define whether to retrieve information from the list

from  QueryBuilder
protected string $prefix

The table prefix

from  QueryBuilder
protected string $model

The model instance

Methods

__construct(string $table, PDO $connection)

QueryBuilder Constructor

select(array $select = ['*'])

Add select column.

as(string $as)

Create the table as

where(string $column, mixed $comparator = '=', mixed $value = null, string $boolean = 'and')

Add where clause into the request

whereRaw(string $where)

Add where clause into the request

orWhere(string $column, mixed $comparator = '=', mixed $value = null)

orWhere, add a condition of type:

whereNull(string $column, string $boolean = 'and')

Where clause with comparison in << is null >>

whereNotNull($column, string $boolean = 'and')

Where clause with comparison in <>

whereBetween(string $column, array $range, string $boolean = 'and')

Where clause with comparison <>

whereNotBetween(string $column, array $range)

WHERE column NOT BETWEEN '' AND ''

whereIn(string $column, array $range, string $boolean = 'and')

Where clause with <> comparison

whereNotIn(string $column, array $range)

Where clause with <> comparison

join(string $table, string $first, mixed $comparator = '=', string|null $second = null)

Join clause

leftJoin(string $table, string $first, mixed $comparator = '=', string|null $second = null)

Left Join clause

rightJoin(string $table, string $first, mixed $comparator = '=', string|null $second = null)

Right Join clause

andOn(string $first, mixed $comparator = '=', string $second = null)

On, if chained with itself must add an << and >> before, otherwise if chained with "orOn" who add a "before"

orOn(string $first, mixed $comparator = '=', string $second = null)

Clause On, followed by a combination by a comparator <> The user has to do an "on()" before using the "orOn"

groupBy(string $column)

Clause Group By

group(string $column) deprecated

Clause Group By

having(string $column, mixed $comparator = '=', mixed $value = null, string $boolean = 'and')

clause having, is used with a groupBy

orderBy(string $column, string $type = 'asc')

Clause Order By

jump(int $offset = 0)

Jump = Offset

take(int $limit)

Take = Limit

int|float
max(string $column)

Max

int|float
min(string $column)

Min

int|float
avg(string $column)

Avg

int|float
sum(string $column)

Sum

int
count(string $column = '*')

Count

array|object|null
get(array $columns = [])

Get informations

object|null
first()

Get the first record

object|null
last()

Get the last record

int
update(array $data = [])

Update action

int
delete()

Delete Action

int
remove(string $column, mixed $comparator = '=', string $value = null)

Remove simplified stream from delete.

int
increment(string $column, int $step = 1)

Action increment, add 1 by default to the specified field

int
decrement(string $column, int $step = 1)

Decrement action, subtracts 1 by default from the specified field

distinct(string $column)

Allows a query with the DISTINCT clause

bool
truncate()

Truncate Action, empty the table

int
insert(array $values)

Insert Action

string|int|bool
insertAndGetLastId(array $values)

InsertAndGetLastId action launches the insert and lastInsertId actions

bool
drop()

Drop Action, remove the table

array
paginate(int $number_of_page, int $current = 0, int $chunk = null)

Paginate, make pagination system

bool
exists(string|null $column = null, mixed $value = null)

Check if rows exists

string
getLastInsertId(string|null $name = null)

Turn back the id of the last insertion

string
jsonSerialize()

JsonSerialize implementation

string
toJson(int $option = 0)

Transformation automatically the result to JSON

string
toSql()

Formats the select request

string
getTable()

Returns the name of the table.

string
getPrefix()

Returns the prefix.

setPrefix(string $prefix)

Modify the prefix

setTable(string $table)

Change the table's name

void
setWhereDataBinding(array $data_binding)

Define the data to associate

string
__toString()

__toString

setModel(string $model)

Set model

string
getModel()

Get model

Details

__construct(string $table, PDO $connection)

QueryBuilder Constructor

Parameters

string $table
PDO $connection

QueryBuilder select(array $select = ['*'])

Add select column.

SELECT $column | SELECT column1, column2, ...

Parameters

array $select

Return Value

QueryBuilder

QueryBuilder as(string $as)

Create the table as

Parameters

string $as

Return Value

QueryBuilder

QueryBuilder where(string $column, mixed $comparator = '=', mixed $value = null, string $boolean = 'and')

Add where clause into the request

WHERE column1 $comparator $value|column

Parameters

string $column
mixed $comparator
mixed $value
string $boolean

Return Value

QueryBuilder

Exceptions

QueryBuilderException

QueryBuilder whereRaw(string $where)

Add where clause into the request

WHERE column1 $comparator $value|column

Parameters

string $where

Return Value

QueryBuilder

QueryBuilder orWhere(string $column, mixed $comparator = '=', mixed $value = null)

orWhere, add a condition of type:

[where column = value or column = value]

Parameters

string $column
mixed $comparator
mixed $value

Return Value

QueryBuilder

Exceptions

QueryBuilderException

QueryBuilder whereNull(string $column, string $boolean = 'and')

Where clause with comparison in << is null >>

WHERE column IS NULL

Parameters

string $column
string $boolean

Return Value

QueryBuilder

QueryBuilder whereNotNull($column, string $boolean = 'and')

Where clause with comparison in <>

WHERE column NOT NULL

Parameters

$column
string $boolean

Return Value

QueryBuilder

QueryBuilder whereBetween(string $column, array $range, string $boolean = 'and')

Where clause with comparison <>

WHERE column BETWEEN '' AND ''

Parameters

string $column
array $range
string $boolean

Return Value

QueryBuilder

Exceptions

QueryBuilderException

QueryBuilder whereNotBetween(string $column, array $range)

WHERE column NOT BETWEEN '' AND ''

Parameters

string $column
array $range

Return Value

QueryBuilder

QueryBuilder whereIn(string $column, array $range, string $boolean = 'and')

Where clause with <> comparison

Parameters

string $column
array $range
string $boolean

Return Value

QueryBuilder

Exceptions

QueryBuilderException

QueryBuilder whereNotIn(string $column, array $range)

Where clause with <> comparison

Parameters

string $column
array $range

Return Value

QueryBuilder

Exceptions

QueryBuilderException

QueryBuilder join(string $table, string $first, mixed $comparator = '=', string|null $second = null)

Join clause

Parameters

string $table
string $first
mixed $comparator
string|null $second

Return Value

QueryBuilder

QueryBuilder leftJoin(string $table, string $first, mixed $comparator = '=', string|null $second = null)

Left Join clause

Parameters

string $table
string $first
mixed $comparator
string|null $second

Return Value

QueryBuilder

Exceptions

QueryBuilderException

QueryBuilder rightJoin(string $table, string $first, mixed $comparator = '=', string|null $second = null)

Right Join clause

Parameters

string $table
string $first
mixed $comparator
string|null $second

Return Value

QueryBuilder

Exceptions

QueryBuilderException

QueryBuilder andOn(string $first, mixed $comparator = '=', string $second = null)

On, if chained with itself must add an << and >> before, otherwise if chained with "orOn" who add a "before"

Parameters

string $first
mixed $comparator
string $second

Return Value

QueryBuilder

Exceptions

QueryBuilderException

QueryBuilder orOn(string $first, mixed $comparator = '=', string $second = null)

Clause On, followed by a combination by a comparator <> The user has to do an "on()" before using the "orOn"

Parameters

string $first
mixed $comparator
string $second

Return Value

QueryBuilder

Exceptions

QueryBuilderException

QueryBuilder groupBy(string $column)

Clause Group By

Parameters

string $column

Return Value

QueryBuilder

QueryBuilder group(string $column) deprecated

deprecated

Clause Group By

Parameters

string $column

Return Value

QueryBuilder

QueryBuilder having(string $column, mixed $comparator = '=', mixed $value = null, string $boolean = 'and')

clause having, is used with a groupBy

Parameters

string $column
mixed $comparator
mixed $value
string $boolean

Return Value

QueryBuilder

QueryBuilder orderBy(string $column, string $type = 'asc')

Clause Order By

Parameters

string $column
string $type

Return Value

QueryBuilder

QueryBuilder jump(int $offset = 0)

Jump = Offset

Parameters

int $offset

Return Value

QueryBuilder

QueryBuilder take(int $limit)

Take = Limit

Parameters

int $limit

Return Value

QueryBuilder

int|float max(string $column)

Max

Parameters

string $column

Return Value

int|float

int|float min(string $column)

Min

Parameters

string $column

Return Value

int|float

int|float avg(string $column)

Avg

Parameters

string $column

Return Value

int|float

int|float sum(string $column)

Sum

Parameters

string $column

Return Value

int|float

int count(string $column = '*')

Count

Parameters

string $column

Return Value

int

array|object|null get(array $columns = [])

Get informations

Parameters

array $columns

Return Value

array|object|null

object|null first()

Get the first record

Return Value

object|null

object|null last()

Get the last record

Return Value

object|null

int update(array $data = [])

Update action

Parameters

array $data

Return Value

int

int delete()

Delete Action

Return Value

int

int remove(string $column, mixed $comparator = '=', string $value = null)

Remove simplified stream from delete.

Parameters

string $column
mixed $comparator
string $value

Return Value

int

Exceptions

QueryBuilderException

int increment(string $column, int $step = 1)

Action increment, add 1 by default to the specified field

Parameters

string $column
int $step

Return Value

int

int decrement(string $column, int $step = 1)

Decrement action, subtracts 1 by default from the specified field

Parameters

string $column
int $step

Return Value

int

QueryBuilder distinct(string $column)

Allows a query with the DISTINCT clause

Parameters

string $column

Return Value

QueryBuilder

bool truncate()

Truncate Action, empty the table

Return Value

bool

int insert(array $values)

Insert Action

The data to be inserted into the database.

Parameters

array $values

Return Value

int

string|int|bool insertAndGetLastId(array $values)

InsertAndGetLastId action launches the insert and lastInsertId actions

Parameters

array $values

Return Value

string|int|bool

bool drop()

Drop Action, remove the table

Return Value

bool

array paginate(int $number_of_page, int $current = 0, int $chunk = null)

Paginate, make pagination system

Parameters

int $number_of_page
int $current
int $chunk

Return Value

array

bool exists(string|null $column = null, mixed $value = null)

Check if rows exists

Parameters

string|null $column
mixed $value

Return Value

bool

Exceptions

string getLastInsertId(string|null $name = null)

Turn back the id of the last insertion

Parameters

string|null $name [optional]

Return Value

string

string jsonSerialize()

JsonSerialize implementation

string toJson(int $option = 0)

Transformation automatically the result to JSON

Parameters

int $option

Return Value

string

string toSql()

Formats the select request

Return Value

string

string getTable()

Returns the name of the table.

Return Value

string

string getPrefix()

Returns the prefix.

Return Value

string

QueryBuilder setPrefix(string $prefix)

Modify the prefix

Parameters

string $prefix

Return Value

QueryBuilder

QueryBuilder setTable(string $table)

Change the table's name

Parameters

string $table

Return Value

QueryBuilder

void setWhereDataBinding(array $data_binding)

Define the data to associate

Parameters

array $data_binding

Return Value

void

string __toString()

__toString

Return Value

string

Builder setModel(string $model)

Set model

Parameters

string $model

Return Value

Builder

string getModel()

Get model

Return Value

string