QueryBuilder
Usage
Constants
Properties
Methods
build
public build()
Builds the final query string
return {str} SQL query string
by<Column_Name>
public by<Column_Name>($val)
Magic method to add WHERE filters for building the final query string. Replace
param {mixed} Simple value, CSV or array of values to filter on
from
public from($table)
Sets the table name to build a query for
param {str} Table name
group
public group($group_str)
Stores a GROUP BY clause (minus the ‘GROUP BY’) for building the final query string.
param {str} GROUP BY clause
limit
public limit($count[, $start = 0])
Creates and stores a LIMIT clause for building the final query string.
param {int} Number of results to limit the result set to (must be greater than 0)
param {int} Starting result set row (must be greater than or equal to 0, default value is 0)
order
public order($order_str)
Stores an ORDER BY clause (minus the ‘ORDER BY’ part) for building the final query string
param {str} ORDER BY clause
querytype
public querytype($type)
Takes in a type of query that is going to be built and verifies that it is on the approved list of query types. Since the query type determines the allowed calls and final query building logic, this should be the first call made.
param {str} Type of query to run
select
public select($fields)
Takes in a CSV string or array of database fields. (e.g., ‘field1, field2 AS bar, COUNT as mycount’, or array(‘field1’, ‘field2’, ‘COUNT AS mycount’))
param {mixed} array or CSV of database fields
set<Column_Name>
public set<Column_Name>($val)
Magic method to add SET field values for building the final query string. Replace
param {mixed} Scalar value
where
public where($where_str)
Stores a raw WHERE clause (minus the ‘WHERE’) for building the final query string
param {str} WHERE clause
