Methods

select()

select(string  $fields) : \Query\Query_Builder

Specifies rows to select in a query

Parameters

string $fields

Returns

\Query\Query_Builder

select_max()

select_max(string  $field, string|boolean  $as = FALSE) : \Query\Query_Builder

Selects the maximum value of a field from a query

Parameters

string $field
string|boolean $as

Returns

\Query\Query_Builder

select_min()

select_min(string  $field, string|boolean  $as = FALSE) : \Query\Query_Builder

Selects the minimum value of a field from a query

Parameters

string $field
string|boolean $as

Returns

\Query\Query_Builder

select_avg()

select_avg(string  $field, string|boolean  $as = FALSE) : \Query\Query_Builder

Selects the average value of a field from a query

Parameters

string $field
string|boolean $as

Returns

\Query\Query_Builder

select_sum()

select_sum(string  $field, string|boolean  $as = FALSE) : \Query\Query_Builder

Selects the sum of a field from a query

Parameters

string $field
string|boolean $as

Returns

\Query\Query_Builder

distinct()

distinct() : \Query\Query_Builder

Adds the 'distinct' keyword to a query

Returns

\Query\Query_Builder

explain()

explain() : \Query\Query_Builder

Shows the query plan for the query

Returns

\Query\Query_Builder

from()

from(string  $tblname) : \Query\Query_Builder

Specify the database table to select from

Parameters

string $tblname

Returns

\Query\Query_Builder

like()

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

Creates a Like clause in the sql statement

Parameters

string $field
mixed $val
string $pos

Returns

\Query\Query_Builder

or_like()

or_like(string  $field, mixed  $val, string  $pos = 'both') : \Query\Query_Builder

Generates an OR Like clause

Parameters

string $field
mixed $val
string $pos

Returns

\Query\Query_Builder

not_like()

not_like(string  $field, mixed  $val, string  $pos = 'both') : \Query\Query_Builder

Generates a NOT LIKE clause

Parameters

string $field
mixed $val
string $pos

Returns

\Query\Query_Builder

or_not_like()

or_not_like(string  $field, mixed  $val, string  $pos = 'both') : \Query\Query_Builder

Generates a OR NOT LIKE clause

Parameters

string $field
mixed $val
string $pos

Returns

\Query\Query_Builder

having()

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

Generates a 'Having' clause

Parameters

mixed $key
mixed $val

Returns

\Query\Query_Builder

or_having()

or_having(mixed  $key, mixed  $val = array()) : \Query\Query_Builder

Generates a 'Having' clause prefixed with 'OR'

Parameters

mixed $key
mixed $val

Returns

\Query\Query_Builder

where()

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

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\Query_Builder

or_where()

or_where(string  $key, mixed  $val = array()) : \Query\Query_Builder

Where clause prefixed with "OR"

Parameters

string $key
mixed $val

Returns

\Query\Query_Builder

where_in()

where_in(mixed  $field, mixed  $val = array()) : \Query\Query_Builder

Where clause with 'IN' statement

Parameters

mixed $field
mixed $val

Returns

\Query\Query_Builder

or_where_in()

or_where_in(string  $field, mixed  $val = array()) : \Query\Query_Builder

Where in statement prefixed with "or"

Parameters

string $field
mixed $val

Returns

\Query\Query_Builder

where_not_in()

where_not_in(string  $field, mixed  $val = array()) : \Query\Query_Builder

WHERE NOT IN (FOO) clause

Parameters

string $field
mixed $val

Returns

\Query\Query_Builder

or_where_not_in()

or_where_not_in(string  $field, mixed  $val = array()) : \Query\Query_Builder

OR WHERE NOT IN (FOO) clause

Parameters

string $field
mixed $val

Returns

\Query\Query_Builder

set()

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

Sets values for inserts / updates / deletes

Parameters

mixed $key
mixed $val

Returns

\Query\Query_Builder

join()

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

Creates a join phrase in a compiled query

Parameters

string $table
string $condition
string $type

Returns

\Query\Query_Builder

group_by()

group_by(mixed  $field) : \Query\Query_Builder

Group the results by the selected field(s)

Parameters

mixed $field

Returns

\Query\Query_Builder

order_by()

order_by(string  $field, string  $type = "") : \Query\Query_Builder

Order the results by the selected field(s)

Parameters

string $field
string $type

Returns

\Query\Query_Builder

limit()

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

Set a limit on the current sql statement

Parameters

integer $limit
integer|boolean $offset

Returns

\Query\Query_Builder

group_start()

group_start() : \Query\Query_Builder

Adds a paren to the current query for query grouping

Returns

\Query\Query_Builder

or_group_start()

or_group_start() : \Query\Query_Builder

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

Returns

\Query\Query_Builder

or_not_group_start()

or_not_group_start() : \Query\Query_Builder

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

Returns

\Query\Query_Builder

get()

get(  $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

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

Returns

\PDOStatement

get_where()

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

Convience method for get() with a where clause

Parameters

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

Returns

\PDOStatement

count_all()

count_all(string  $table) : integer

Retrieve the number of rows in the selected table

Parameters

string $table

Returns

integer

count_all_results()

count_all_results(string  $table = '') : integer

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

Parameters

string $table

Returns

integer

insert()

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

Creates an insert clause, and executes it

Parameters

string $table
mixed $data

Returns

\PDOStatement

insert_batch()

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

Creates and executes a batch insertion query

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

delete()

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

Deletes data from a table

Parameters

string $table
mixed $where

Returns

\PDOStatement

get_compiled_select()

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

Returns the generated 'select' sql query

Parameters

string $table
boolean $reset

Returns

string

get_compiled_insert()

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

Returns the generated 'insert' sql query

Parameters

string $table
boolean $reset

Returns

string

get_compiled_update()

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

Returns the generated 'update' sql query

Parameters

string $table
boolean $reset

Returns

string

get_compiled_delete()

get_compiled_delete(string  $table = "", boolean  $reset = TRUE) : string

Returns the generated 'delete' sql query

Parameters

string $table
boolean $reset

Returns

string

reset_query()

reset_query() : void

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