Class Details
Helper class for building sql statements progmatically.
Class Methods
public SQLBuilder __construct ( Connection $connection , string $table )
Constructor.
- Connection $connection - A database connection object
- string $table - Name of a table
- throws: ActiveRecordException if connection was invalid
public array bind_values ( )
Returns the bind values.
public static A create_conditions_from_underscored_string ( Connection $connection , $name $name , [ $values &$values = array()] , [ $map &$map = null] )
Converts a string like "id_and_name_or_z" into a conditions value like array("id=? AND name=? OR z=?", values, ...).
- Connection $connection -
- $name $name - Underscored string
- $values &$values - Array of values for the field names. This is used to determine what kind of bind marker to use: =?, IN(?), IS NULL
- $map &$map - A hash of "mapped_column_name" => "real_column_name"
- return: conditions array in the form array(sql_string, value1, value2,...)
public static array create_hash_from_underscored_string ( string $name , [ $args &$values = array()] , [ $map &$map = null] )
Like create_conditions_from_underscored_string but returns a hash of name => value array instead.
- string $name - A string containing attribute names connected with _and_ or _or_
- $args &$values - Array of values for each attribute in $name
- $map &$map - A hash of "mapped_column_name" => "real_column_name"
- return: A hash of array(name => value, ...)
public void delete ( )
public void get_where_values ( )
public void group ( $group )
- $group -
public void having ( $having )
- $having -
public void insert ( $hash , [ $pk = null] , [ $sequence_name = null] )
- $hash -
- $pk -
- $sequence_name -
public void joins ( $joins )
- $joins -
public void limit ( $limit )
- $limit -
public void offset ( $offset )
- $offset -
public void order ( $order )
- $order -
public static void reverse_order ( $order )
Reverses an order clause.
- $order -
public void select ( $select )
- $select -
public string to_s ( )
Returns the SQL string.
public void update ( $mixed )
- $mixed -
public void where ( )
public string __toString ( )
Returns the SQL string.