class SQLBuilder (View source)

Helper class for building sql statements progmatically.

Methods

__construct(Connection $connection, string $table)

Constructor.

string
__toString()

Returns the SQL string.

string
to_s()

Returns the SQL string.

array
bind_values()

Returns the bind values.

get_where_values()

No description

where()

No description

order($order)

No description

group($group)

No description

having($having)

No description

limit($limit)

No description

offset($offset)

No description

select($select)

No description

joins($joins)

No description

insert($hash, $pk = null, $sequence_name = null)

No description

update($mixed)

No description

delete()

No description

static 
reverse_order($order)

Reverses an order clause.

static A
create_conditions_from_underscored_string(Connection $connection, $name, $values = array(), $map = null)

Converts a string like "id_and_name_or_z" into a conditions value like array("id=? AND name=? OR z=?", values, .

static array
create_hash_from_underscored_string($name, $values = array(), $map = null)

Like create_conditions_from_underscored_string but returns a hash of name => value array instead.

Details

SQLBuilder __construct(Connection $connection, string $table)

Constructor.

Parameters

Connection $connection A database connection object
string $table Name of a table

Return Value

SQLBuilder

Exceptions

ActiveRecordException if connection was invalid

string __toString()

Returns the SQL string.

Return Value

string

string to_s()

Returns the SQL string.

Return Value

string

See also

__toString

array bind_values()

Returns the bind values.

Return Value

array

get_where_values()

where()

order($order)

Parameters

$order

group($group)

Parameters

$group

having($having)

Parameters

$having

limit($limit)

Parameters

$limit

offset($offset)

Parameters

$offset

select($select)

Parameters

$select

joins($joins)

Parameters

$joins

insert($hash, $pk = null, $sequence_name = null)

Parameters

$hash
$pk
$sequence_name

update($mixed)

Parameters

$mixed

delete()

static reverse_order($order)

Reverses an order clause.

Parameters

$order

static A create_conditions_from_underscored_string(Connection $connection, $name, $values = array(), $map = null)

Converts a string like "id_and_name_or_z" into a conditions value like array("id=? AND name=? OR z=?", values, .

..).

Parameters

Connection $connection
$name Underscored string
$values Array of values for the field names. This is used to determine what kind of bind marker to use: =?, IN(?), IS NULL
$map A hash of "mapped_column_name" => "real_column_name"

Return Value

A conditions array in the form array(sql_string, value1, value2,...)

static array create_hash_from_underscored_string($name, $values = array(), $map = null)

Like create_conditions_from_underscored_string but returns a hash of name => value array instead.

Parameters

$name
$values
$map

Return Value

array A hash of array(name => value, ...)