SQL builder class. More...
Public Member Functions | |
__construct ($sql_string=array()) | |
Constructor. | |
set_sql ($sql_string) | |
Set the SQL. | |
get_array () | |
Get the SQL statement as array. | |
set_order_by ($item) | |
Set the ORDER BY clause. | |
render () | |
Render the element as SQL string. | |
__toString () | |
Automatically render. | |
![]() | |
__call ($function, $params) | |
The 'magic' call method will get/set for us invoked when the interpreter can not find a method the user is asking for. | |
set_parameters ($arguments) | |
Set variables from an array to member fields requires $this->optional_arguments or $this->required_arguments to have been set by the subclass. |
Static Public Member Functions | |
static | to_array ($sql_string) |
Works through SQL string and parses into an array. | |
static | array_to_sql ($array) |
Creates a SQL string from an array of statement blocks. |
Public Attributes | |
$select = '' | |
SELECT clause. | |
$from = '' | |
FROM clause. | |
$where = '' | |
WHERE clause. | |
$group_by = '' | |
GROUP BY clause. | |
$having = '' | |
HAVING clause. | |
$order_by = '' | |
ORDER BY clause. | |
$limit = '' | |
LIMIT clause. | |
$offset = '' | |
OFFSET clause. |
Protected Attributes | |
$sql_string = '' | |
the SQL string | |
$sql_array = array() | |
array of key-value pairs of SQL statement blocks, e.g. array('SELECT'=>'*','FROM'=>'table') | |
![]() | |
$optional_arguments = array() | |
Array of options that can be set to variables. | |
$required_arguments = array() | |
Array of options that need to be set to variables. |
SQL builder class.
Assists in building, parsing and manipulating SQL statements
Sql::__construct | ( | $sql_string = array() | ) |
Constructor.
Parses SQL string if provided
|
static |
Creates a SQL string from an array of statement blocks.
$array | an array of key-value pairs of SQL statement blocks, e.g. array('SELECT'=>'*','FROM'=>'table') |
Sql::set_sql | ( | $sql_string | ) |
Set the SQL.
Parse into an array
$sql_string | SQL string to parse |