Methods

select()

select(string  $fields) : \Query\QueryBuilderInterface

Specifies rows to select in a query

Parameters

string $fields

Returns

\Query\QueryBuilderInterface

selectMax()

selectMax(string  $field, string|boolean  $as = FALSE) : \Query\QueryBuilderInterface

Selects the maximum value of a field from a query

Parameters

string $field
string|boolean $as

Returns

\Query\QueryBuilderInterface

selectMin()

selectMin(string  $field, string|boolean  $as = FALSE) : \Query\QueryBuilderInterface

Selects the minimum value of a field from a query

Parameters

string $field
string|boolean $as

Returns

\Query\QueryBuilderInterface

selectAvg()

selectAvg(string  $field, string|boolean  $as = FALSE) : \Query\QueryBuilderInterface

Selects the average value of a field from a query

Parameters

string $field
string|boolean $as

Returns

\Query\QueryBuilderInterface

selectSum()

selectSum(string  $field, string|boolean  $as = FALSE) : \Query\QueryBuilderInterface

Selects the sum of a field from a query

Parameters

string $field
string|boolean $as

Returns

\Query\QueryBuilderInterface

from()

from(string  $tblname) : \Query\QueryBuilderInterface

Specify the database table to select from

Parameters

string $tblname

Returns

\Query\QueryBuilderInterface

like()

like(string  $field, mixed  $val, string  $pos = 'both') : \Query\QueryBuilderInterface

Creates a Like clause in the sql statement

Parameters

string $field
mixed $val
string $pos

Returns

\Query\QueryBuilderInterface

orLike()

orLike(string  $field, mixed  $val, string  $pos = 'both') : \Query\QueryBuilderInterface

Generates an OR Like clause

Parameters

string $field
mixed $val
string $pos

Returns

\Query\QueryBuilderInterface

notLike()

notLike(string  $field, mixed  $val, string  $pos = 'both') : \Query\QueryBuilderInterface

Generates a NOT LIKE clause

Parameters

string $field
mixed $val
string $pos

Returns

\Query\QueryBuilderInterface

orNotLike()

orNotLike(string  $field, mixed  $val, string  $pos = 'both') : \Query\QueryBuilderInterface

Generates a OR NOT LIKE clause

Parameters

string $field
mixed $val
string $pos

Returns

\Query\QueryBuilderInterface

having()

having(mixed  $key, mixed  $val = array()) : \Query\QueryBuilderInterface

Generates a 'Having' clause

Parameters

mixed $key
mixed $val

Returns

\Query\QueryBuilderInterface

orHaving()

orHaving(mixed  $key, mixed  $val = array()) : \Query\QueryBuilderInterface

Generates a 'Having' clause prefixed with 'OR'

Parameters

mixed $key
mixed $val

Returns

\Query\QueryBuilderInterface

where()

where(mixed  $key, mixed  $val = array(), boolean  $escape = NULL) : \Query\QueryBuilderInterface

Specify condition(s) in the where clause of a query Note: this function works with key / value, or a passed array with key / value pairs

Parameters

mixed $key
mixed $val
boolean $escape

Returns

\Query\QueryBuilderInterface

orWhere()

orWhere(string  $key, mixed  $val = array()) : \Query\QueryBuilderInterface

Where clause prefixed with "OR"

Parameters

string $key
mixed $val

Returns

\Query\QueryBuilderInterface

whereIn()

whereIn(mixed  $field, mixed  $val = array()) : \Query\QueryBuilderInterface

Where clause with 'IN' statement

Parameters

mixed $field
mixed $val

Returns

\Query\QueryBuilderInterface

orWhereIn()

orWhereIn(string  $field, mixed  $val = array()) : \Query\QueryBuilderInterface

Where in statement prefixed with "or"

Parameters

string $field
mixed $val

Returns

\Query\QueryBuilderInterface

whereNotIn()

whereNotIn(string  $field, mixed  $val = array()) : \Query\QueryBuilderInterface

WHERE NOT IN (FOO) clause

Parameters

string $field
mixed $val

Returns

\Query\QueryBuilderInterface

orWhereNotIn()

orWhereNotIn(string  $field, mixed  $val = array()) : \Query\QueryBuilderInterface

OR WHERE NOT IN (FOO) clause

Parameters

string $field
mixed $val

Returns

\Query\QueryBuilderInterface

set()

set(mixed  $key, mixed  $val = NULL) : \Query\QueryBuilderInterface

Sets values for inserts / updates / deletes

Parameters

mixed $key
mixed $val

Returns

\Query\QueryBuilderInterface

join()

join(string  $table, string  $condition, string  $type = '') : \Query\QueryBuilderInterface

Creates a join phrase in a compiled query

Parameters

string $table
string $condition
string $type

Returns

\Query\QueryBuilderInterface

groupBy()

groupBy(mixed  $field) : \Query\QueryBuilderInterface

Group the results by the selected field(s)

Parameters

mixed $field

Returns

\Query\QueryBuilderInterface

orderBy()

orderBy(string  $field, string  $type = "") : \Query\QueryBuilderInterface

Order the results by the selected field(s)

Parameters

string $field
string $type

Returns

\Query\QueryBuilderInterface

limit()

limit(integer  $limit, integer|boolean  $offset = FALSE) : \Query\QueryBuilderInterface

Set a limit on the current sql statement

Parameters

integer $limit
integer|boolean $offset

Returns

\Query\QueryBuilderInterface

groupStart()

groupStart() : \Query\QueryBuilderInterface

Adds a paren to the current query for query grouping

Returns

\Query\QueryBuilderInterface

notGroupStart()

notGroupStart() : \Query\QueryBuilderInterface

Adds a paren to the current query for query grouping, prefixed with 'NOT'

Returns

\Query\QueryBuilderInterface

orGroupStart()

orGroupStart() : \Query\QueryBuilderInterface

Adds a paren to the current query for query grouping, prefixed with 'OR'

Returns

\Query\QueryBuilderInterface

orNotGroupStart()

orNotGroupStart() : \Query\QueryBuilderInterface

Adds a paren to the current query for query grouping, prefixed with 'OR NOT'

Returns

\Query\QueryBuilderInterface

get()

get(string  $table = '', integer|boolean  $limit = FALSE, integer|boolean  $offset = FALSE) : \PDOStatement

Select and retrieve all records from the current table, and/or execute current compiled query

Parameters

string $table
integer|boolean $limit
integer|boolean $offset

Returns

\PDOStatement

getWhere()

getWhere(string  $table, array  $where = array(), integer|boolean  $limit = FALSE, integer|boolean  $offset = FALSE) : \PDOStatement

Convenience method for get() with a where clause

Parameters

string $table
array $where
integer|boolean $limit
integer|boolean $offset

Returns

\PDOStatement

countAll()

countAll(string  $table) : integer

Retrieve the number of rows in the selected table

Parameters

string $table

Returns

integer

countAllResults()

countAllResults(string  $table = '', boolean  $reset = TRUE) : integer

Retrieve the number of results for the generated query - used in place of the get() method

Parameters

string $table
boolean $reset
  • Whether to keep the query after counting the results

Returns

integer

insert()

insert(string  $table, mixed  $data = array()) : \PDOStatement

Creates an insert clause, and executes it

Parameters

string $table
mixed $data

Returns

\PDOStatement

insertBatch()

insertBatch(string  $table, array  $data = array()) : \PDOStatement|null

Creates and executes a batch insertion query

Parameters

string $table
array $data

Returns

\PDOStatement|null

replace()

replace(string  $table, array  $data = array()) : \PDOStatement|null

Insertion with automatic overwrite, rather than attempted duplication

Parameters

string $table
array $data

Returns

\PDOStatement|null

update()

update(string  $table, mixed  $data = array()) : \PDOStatement

Creates an update clause, and executes it

Parameters

string $table
mixed $data

Returns

\PDOStatement

updateBatch()

updateBatch(string  $table, array|object  $data, string  $where) : integer|null

Creates a batch update, and executes it.

Returns the number of affected rows

Parameters

string $table
array|object $data
string $where

Returns

integer|null

delete()

delete(string  $table, mixed  $where = '') : \PDOStatement

Deletes data from a table

Parameters

string $table
mixed $where

Returns

\PDOStatement

getCompiledSelect()

getCompiledSelect(string  $table = '', boolean  $reset = TRUE) : string

Returns the generated 'select' sql query

Parameters

string $table
boolean $reset

Returns

string

getCompiledInsert()

getCompiledInsert(string  $table, boolean  $reset = TRUE) : string

Returns the generated 'insert' sql query

Parameters

string $table
boolean $reset

Returns

string

getCompiledUpdate()

getCompiledUpdate(string  $table = '', boolean  $reset = TRUE) : string

Returns the generated 'update' sql query

Parameters

string $table
boolean $reset

Returns

string

getCompiledDelete()

getCompiledDelete(string  $table = '', boolean  $reset = TRUE) : string

Returns the generated 'delete' sql query

Parameters

string $table
boolean $reset

Returns

string

resetQuery()

resetQuery() : void

Clear out the class variables, so the next query can be run