classe QueryBuilder implémente JsonSerializable (Voir la source)

Propriétés

protected string $table

The table name

protected string $select

Select statement collector

protected string $where

Where statement collector

protected array $where_data_binding

The data binding information

protected string $join

Join statement collector

protected string $limit

Limit statement collector

protected string $group

Group statement collector

protected string $having

Having statement collector

protected string $order

Order By statement collector

protected string $as

Define the table as

protected PDO $connection

The PDO instance

protected bool $first

Define whether to retrieve information from the list

protected string $prefix

The table prefix

Méthodes

__construct(string $table, PDO $connection)

QueryBuilder Constructor

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

Add select column.

as(string $as)

Create the table as

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

Add where clause into the request

whereRaw(string $where)

Add where clause into the request

orWhere(string $column, string $comp = '=', 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, string $comp = '=', string $second = null)

Join clause

leftJoin(string $table, string $first, string $comp = '=', string $second = null)

Left Join clause

rightJoin(string $table, string $first, string $comp = '=', string $second = null)

Right Join clause

andOn(string $first, string $comp = '=', 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, string $comp = '=', 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) déprécié

Clause Group By

having(string $column, string $comp = '=', 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

QueryBuilder|number|array|object
max(string $column)

Max

QueryBuilder|number|object
min(string $column)

Min

QueryBuilder|number|object
avg(string $column)

Avg

QueryBuilder|number|object
sum(string $column)

Sum

int
count(string $column = '*')

Count

array|stdClass
get(array $columns = [])

Get make, only on the select request If the first selection mode is not active

object|null
first()

Get the first record

mixed
last()

Get the last record

int
update(array $data = [])

Update action

int
delete()

Delete Action

int
remove(string $column, string $comp = '=', 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

int
insertAndGetLastId(array $values)

InsertAndGetLastId action launches the insert and lastInsertId actions

mixed
drop()

Drop Action, remove the table

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

Paginate, make pagination system

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

Check if a value already exists in the DB

string
getLastInsertId(string $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

setWhereDataBinding(array $data_binding)

Define the data to associate

string
__toString()

__toString

Détails

__construct(string $table, PDO $connection)

QueryBuilder Constructor

Paramètres

string $table
PDO $connection

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

Add select column.

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

Paramètres

array $select

Valeur de retour

QueryBuilder

QueryBuilder as(string $as)

Create the table as

Paramètres

string $as

Valeur de retour

QueryBuilder

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

Add where clause into the request

WHERE column1 $comp $value|column

Paramètres

string $column
string $comp
mixed $value
string $boolean

Valeur de retour

QueryBuilder

Exceptions

QueryBuilderException

QueryBuilder whereRaw(string $where)

Add where clause into the request

WHERE column1 $comp $value|column

Paramètres

string $where

Valeur de retour

QueryBuilder

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

orWhere, add a condition of type:

[where column = value or column = value]

Paramètres

string $column
string $comp
mixed $value

Valeur de retour

QueryBuilder

Exceptions

QueryBuilderException

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

Where clause with comparison in << is null >>

WHERE column IS NULL

Paramètres

string $column
string $boolean

Valeur de retour

QueryBuilder

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

Where clause with comparison in <>

WHERE column NOT NULL

Paramètres

$column
string $boolean

Valeur de retour

QueryBuilder

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

Where clause with comparison <>

WHERE column BETWEEN '' AND ''

Paramètres

string $column
array $range
string $boolean

Valeur de retour

QueryBuilder

Exceptions

QueryBuilderException

QueryBuilder whereNotBetween(string $column, array $range)

WHERE column NOT BETWEEN '' AND ''

Paramètres

string $column
array $range

Valeur de retour

QueryBuilder

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

Where clause with <> comparison

Paramètres

string $column
array $range
string $boolean

Valeur de retour

QueryBuilder

Exceptions

QueryBuilderException

QueryBuilder whereNotIn(string $column, array $range)

Where clause with <> comparison

Paramètres

string $column
array $range

Valeur de retour

QueryBuilder

Exceptions

QueryBuilderException

QueryBuilder join(string $table, string $first, string $comp = '=', string $second = null)

Join clause

Paramètres

string $table
string $first
string $comp
string $second

Valeur de retour

QueryBuilder

QueryBuilder leftJoin(string $table, string $first, string $comp = '=', string $second = null)

Left Join clause

Paramètres

string $table
string $first
string $comp
string $second

Valeur de retour

QueryBuilder

Exceptions

QueryBuilderException

QueryBuilder rightJoin(string $table, string $first, string $comp = '=', string $second = null)

Right Join clause

Paramètres

string $table
string $first
string $comp
string $second

Valeur de retour

QueryBuilder

Exceptions

QueryBuilderException

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

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

Paramètres

string $first
string $comp
string $second

Valeur de retour

QueryBuilder

Exceptions

QueryBuilderException

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

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

Paramètres

string $first
string $comp
string $second

Valeur de retour

QueryBuilder

Exceptions

QueryBuilderException

QueryBuilder groupBy(string $column)

Clause Group By

Paramètres

string $column

Valeur de retour

QueryBuilder

QueryBuilder group(string $column) déprécié

déprécié

Clause Group By

Paramètres

string $column

Valeur de retour

QueryBuilder

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

clause having, is used with a groupBy

Paramètres

string $column
string $comp
mixed $value
string $boolean

Valeur de retour

QueryBuilder

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

Clause Order By

Paramètres

string $column
string $type

Valeur de retour

QueryBuilder

QueryBuilder jump(int $offset = 0)

Jump = Offset

Paramètres

int $offset

Valeur de retour

QueryBuilder

QueryBuilder take(int $limit)

Take = Limit

Paramètres

int $limit

Valeur de retour

QueryBuilder

QueryBuilder|number|array|object max(string $column)

Max

Paramètres

string $column

Valeur de retour

QueryBuilder|number|array|object

QueryBuilder|number|object min(string $column)

Min

Paramètres

string $column

Valeur de retour

QueryBuilder|number|object

QueryBuilder|number|object avg(string $column)

Avg

Paramètres

string $column

Valeur de retour

QueryBuilder|number|object

QueryBuilder|number|object sum(string $column)

Sum

Paramètres

string $column

Valeur de retour

QueryBuilder|number|object

int count(string $column = '*')

Count

Paramètres

string $column

Valeur de retour

int

array|stdClass get(array $columns = [])

Get make, only on the select request If the first selection mode is not active

Paramètres

array $columns

Valeur de retour

array|stdClass

Exceptions

object|null first()

Get the first record

Valeur de retour

object|null

mixed last()

Get the last record

Valeur de retour

mixed

int update(array $data = [])

Update action

Paramètres

array $data

Valeur de retour

int

int delete()

Delete Action

Valeur de retour

int

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

Remove simplified stream from delete.

Paramètres

string $column
string $comp
string $value

Valeur de retour

int

Exceptions

QueryBuilderException

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

Action increment, add 1 by default to the specified field

Paramètres

string $column
int $step

Valeur de retour

int

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

Decrement action, subtracts 1 by default from the specified field

Paramètres

string $column
int $step

Valeur de retour

int

QueryBuilder distinct(string $column)

Allows a query with the DISTINCT clause

Paramètres

string $column

Valeur de retour

QueryBuilder

bool truncate()

Truncate Action, empty the table

Valeur de retour

bool

int insert(array $values)

Insert Action

The data to be inserted into the database.

Paramètres

array $values

Valeur de retour

int

int insertAndGetLastId(array $values)

InsertAndGetLastId action launches the insert and lastInsertId actions

Paramètres

array $values

Valeur de retour

int

mixed drop()

Drop Action, remove the table

Valeur de retour

mixed

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

Paginate, make pagination system

Paramètres

int $number_of_page
int $current
int $chunk

Valeur de retour

Collection

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

Check if a value already exists in the DB

Paramètres

string $column
mixed $value

Valeur de retour

bool

Exceptions

QueryBuilderException

string getLastInsertId(string $name = null)

Turn back the id of the last insertion

Paramètres

string $name [optional]

Valeur de retour

string

string jsonSerialize()

JsonSerialize implementation

string toJson(int $option = 0)

Transformation automatically the result to JSON

Paramètres

int $option

Valeur de retour

string

string toSql()

Formats the select request

Valeur de retour

string

string getTable()

Returns the name of the table.

Valeur de retour

string

string getPrefix()

Returns the prefix.

Valeur de retour

string

setPrefix(string $prefix)

Modify the prefix

Paramètres

string $prefix

QueryBuilder setTable(string $table)

Change the table's name

Paramètres

string $table

Valeur de retour

QueryBuilder

setWhereDataBinding(array $data_binding)

Define the data to associate

Paramètres

array $data_binding

string __toString()

__toString

Valeur de retour

string