public static
stdClass
|
#
keywordValue( string $keyword = "DEFAULT" )
Returns a stdClass object used to identify keyword values (i.e. DEFAULT) that
can be set in Record and that should never be bound or escaped
Returns a stdClass object used to identify keyword values (i.e. DEFAULT) that
can be set in Record and that should never be bound or escaped
Parameters
- $keyword
string $keyword The name of the keyword to set
Returns
stdClass
An object used to identify the keyword value
|
public
reference
|
#
setField( array $name, array $attributes = null, mixed $add = true )
Sets a field with various options
Sets a field with various options
Parameters
- $name
array $attributes An array of attributes that may contain the following: - type The
type of field - size The size of the field. If type is "varchar" size could be
"64" to produce "varchar(64)" (optional) - unsigned Set to true to set this
field as unsigned (optional) - auto_increment Set to true to set this field to
auto_increment (optional) - default Used to define a default value for the field
(optional) - is_null Set to true if this field
- $attributes
boolean $add True to add the field, false to drop the field
- $add
Returns
reference to this
|
public
reference
|
#
setKey( array $fields, string $type, string $name = null, boolean $add = true )
Sets a key to be added to the table being created or altered
Sets a key to be added to the table being created or altered
Parameters
- $fields
array $fields A numerical array of fields to set as a key
- $type
string $type The type of key ("index", "primary", "unique")
- $name
string $name The name of the key, will default to the first value in $fields if null
- $add
boolean $add True to add the key, false to drop the key
Returns
reference to this
|
public
|
#
create( string $table, boolean $if_not_exists = false )
Creates a table with the given name
Creates a table with the given name
Parameters
- $table
string $table The name of the table to create
- $if_not_exists
boolean $if_not_exists If true will create the table IFF the table does not exist
|
public
|
#
alter( string $table )
Alters a table with the given name
Alters a table with the given name
Parameters
- $table
string $table The name of the table to alter
|
public
|
#
truncate( string $table )
Truncates a table with the given name
Truncates a table with the given name
Parameters
- $table
string $table The name of the table to truncate
|
public
|
#
drop( string $table, boolean $if_exists = false )
Drops a table with the given name
Drops a table with the given name
Parameters
- $table
string $table The name of the table to create
- $if_exists
boolean $if_exists If true will drop the table only if it exists
|
public
|
#
set( string $field, string $value, boolean $bind_value = true, boolean $escape = true )
Set fields for inserting or updating
Set fields for inserting or updating
Parameters
- $field
string $field The field name, or table.field name
- $value
string $value The value to set or insert into this field
- $bind_value
boolean $bind_value True to treat $value as a bound value (i.e. a string or integer,
rather than an table or table field)
- $escape
boolean $escape True to escape the value, false otherwise
|
public
|
#
insert( string $table, array $values = null, array $value_keys = null )
Inserts values into a table
Inserts values into a table
Parameters
- $table
string $table The table name to insert
- $values
array $values The field/value pairs to insert into this table
- $value_keys
array $value_keys An array of keys reperesenting fields to accept for insertion
See
|
public
|
#
update( string $table, array $values = null, array $value_keys = null )
Updates values in a table
Updates values in a table
Parameters
- $table
string $table The table to update
- $values
array $values The field/value pairs to update in this table
- $value_keys
See
|
public
|
#
delete( array $columns = null, boolean $escape = true )
Deletes columns from the currently-set tables
Deletes columns from the currently-set tables
Parameters
- $columns
array $columns The tables to delete from, null to delete from all
- $escape
boolean $escape True to escape $columns, false otherwise
|
public
reference
|
#
select( mixed $columns = "*", boolean $escape = true )
Sets the columns to select from
Sets the columns to select from
Parameters
- $columns
mixed $columns The table columns to select, or a string containing a single column
- $escape
boolean $escape True to escape $columns, false otherwise
Returns
reference to this
|
public
reference
|
#
from( mixed $table )
Sets the tuples to query from
Sets the tuples to query from
Parameters
- $table
mixed $table The table (string) or subqueries (array) to query from
Returns
reference to this
|
public
reference
|
#
join( string $table, string $field = null, string $op = null, string $value = null, boolean $bind_value = true, boolean $escape = true )
Sets the tables to join on into a sql statement
Sets the tables to join on into a sql statement
Parameters
- $table
string $table The table to join on
- $field
string $field The field for comparison
- $op
string $op The operator to compare on
- $value
string $value The value to compare with
- $bind_value
boolean $bind_value True to treat $value as a bound value (i.e. a string or integer,
rather than an table or table field)
- $escape
boolean $escape True to escape the value, false otherwise
Returns
reference to this
|
public
reference
|
#
leftJoin( string $table, string $field = null, string $op = null, string $value = null, boolean $bind_value = true, boolean $escape = true )
Sets the tables to join on into a sql statement
Sets the tables to join on into a sql statement
Parameters
- $table
string $table The table to join on
- $field
string $field The field for comparison
- $op
string $op The operator to compare on
- $value
string $value The value to compare with
- $bind_value
boolean $bind_value True to treat $value as a bound value (i.e. a string or integer,
rather than an table or table field)
- $escape
boolean $escape True to escape the value, false otherwise
Returns
reference to this
|
public
reference
|
#
rightJoin( string $table, string $field = null, string $op = null, string $value = null, boolean $bind_value = true, boolean $escape = true )
Sets the tables to join on into a sql statement
Sets the tables to join on into a sql statement
Parameters
- $table
string $table The table to join on
- $field
string $field The field for comparison
- $op
string $op The operator to compare on
- $value
string $value The value to compare with
- $bind_value
boolean $bind_value True to treat $value as a bound value (i.e. a string or integer,
rather than an table or table field)
- $escape
boolean $escape True to escape the value, false otherwise
Returns
reference to this
|
public
reference
|
#
innerJoin( string $table, string $field = null, string $op = null, string $value = null, boolean $bind_value = true, boolean $escape = true )
Sets the tables to join on into a sql statement
Sets the tables to join on into a sql statement
Parameters
- $table
string $table The table to join on
- $field
string $field The field for comparison
- $op
string $op The operator to compare on
- $value
string $value The value to compare with
- $bind_value
boolean $bind_value True to treat $value as a bound value (i.e. a string or integer,
rather than an table or table field)
- $escape
boolean $escape True to escape the value, false otherwise
Returns
reference to this
|
public
reference
|
#
on( string $field, string $op, string $value, boolean $bind_value = true, boolean $escape = true )
Sets the "on" conditional for the next join statement
Sets the "on" conditional for the next join statement
Parameters
- $field
string $field The field for comparison
- $op
string $op The operator to compare on
- $value
string $value The value to compare with
- $bind_value
boolean $bind_value True to treat $value as a bound value (i.e. a string or integer,
rather than an table or table field)
- $escape
boolean $escape True to escape the value, false otherwise
Returns
reference to this
|
public
reference
|
#
orOn( string $field, string $op, string $value, boolean $bind_value = true, boolean $escape = true )
Sets the "on" conditional as an "or" option for the next join statement
Sets the "on" conditional as an "or" option for the next join statement
Parameters
- $field
string $field The field for comparison
- $op
string $op The operator to compare on
- $value
string $value The value to compare with
- $bind_value
boolean $bind_value True to treat $value as a bound value (i.e. a string or integer,
rather than an table or table field)
- $escape
boolean $escape True to escape the value, false otherwise
Returns
reference to this
|
public
reference
|
#
where( string $field, string $op, string $value, boolean $bind_value = true, boolean $escape = true )
Sets the where condition of a query with an AND statement
Sets the where condition of a query with an AND statement
Parameters
- $field
string $field The field for comparison
- $op
string $op The operator to compare on
- $value
string $value The value to compare with
- $bind_value
boolean $bind_value True to treat $value as a bound value (i.e. a string or integer,
rather than an table or table field)
- $escape
boolean $escape True to escape the value, false otherwise
Returns
reference to this
|
public
reference
|
#
orWhere( string $field, string $op, string $value, boolean $bind_value = true, boolean $escape = true )
Sets the where condition of a query with an OR statement
Sets the where condition of a query with an OR statement
Parameters
- $field
string $field The field for comparison
- $op
string $op The operator to compare on
- $value
string $value The value to compare with
- $bind_value
boolean $bind_value True to treat $value as a bound value (i.e. a string or integer,
rather than an table or table field)
- $escape
boolean $escape True to escape the value, false otherwise
Returns
reference to this
|
public
reference
|
#
duplicate( string $field, string $op, string $value, boolean $bind_value = true, boolean $escape = true )
Sets the on duplicate key condition of a query
Sets the on duplicate key condition of a query
Parameters
- $field
string $field The field for comparison
- $op
string $op The operator to compare on
- $value
string $value The value to compare with
- $bind_value
boolean $bind_value True to treat $value as a bound value (i.e. a string or integer,
rather than an table or table field)
- $escape
boolean $escape True to escape the value, false otherwise
Returns
reference to this
|
public
reference
|
#
like( string $field, string $value, boolean $bind_value = true, boolean $escape = true )
Sets the where condition of a query with a LIKE statement on AND
Sets the where condition of a query with a LIKE statement on AND
Parameters
- $field
string $field The field for comparison
- $value
string $value The value to compare with
- $bind_value
boolean $bind_value True to treat $value as a bound value (i.e. a string or integer,
rather than an table or table field)
- $escape
boolean $escape True to escape the value, false otherwise
Returns
reference to this
|
public
reference
|
#
notLike( string $field, string $value, boolean $bind_value = true, boolean $escape = true )
Sets the where condition of a query with a NOT LIKE statement on AND
Sets the where condition of a query with a NOT LIKE statement on AND
Parameters
- $field
string $field The field for comparison
- $value
string $value The value to compare with
- $bind_value
boolean $bind_value True to treat $value as a bound value (i.e. a string or integer,
rather than an table or table field)
- $escape
boolean $escape True to escape the value, false otherwise
Returns
reference to this
|
public
reference
|
#
orLike( string $field, string $value, boolean $bind_value = true, boolean $escape = true )
Sets the where condition of a query with a LIKE statement on OR
Sets the where condition of a query with a LIKE statement on OR
Parameters
- $field
string $field The field for comparison
- $value
string $value The value to compare with
- $bind_value
boolean $bind_value True to treat $value as a bound value (i.e. a string or integer,
rather than an table or table field)
- $escape
boolean $escape True to escape the value, false otherwise
Returns
reference to this
|
public
reference
|
#
orNotLike( string $field, string $value, boolean $bind_value = true, boolean $escape = true )
Sets the where condition of a query with a NOT LIKE statement on OR
Sets the where condition of a query with a NOT LIKE statement on OR
Parameters
- $field
string $field The field for comparison
- $value
string $value The value to compare with
- $bind_value
boolean $bind_value True to treat $value as a bound value (i.e. a string or integer,
rather than an table or table field)
- $escape
boolean $escape True to escape the value, false otherwise
Returns
reference to this
|
public
reference
|
#
having( string $field, string $op, string $value, boolean $bind_value = true, boolean $escape = true )
Sets the having condition of a query with an AND statement
Sets the having condition of a query with an AND statement
Parameters
- $field
string $field The field for comparison
- $op
string $op The operator to compare on
- $value
string $value The value to compare with
- $bind_value
boolean $bind_value True to treat $value as a bound value (i.e. a string or integer,
rather than an table or table field)
- $escape
boolean $escape True to escape the value, false otherwise
Returns
reference to this
|
public
reference
|
#
orHaving( string $field, string $op, string $value, boolean $bind_value = true, boolean $escape = true )
Sets the having condition of a query with an OR statement
Sets the having condition of a query with an OR statement
Parameters
- $field
string $field The field for comparison
- $op
string $op The operator to compare on
- $value
string $value The value to compare with
- $bind_value
boolean $bind_value True to treat $value as a bound value (i.e. a string or integer,
rather than an table or table field)
- $escape
boolean $escape True to escape the value, false otherwise
Returns
reference to this
|
public
reference
|
#
group( mixed $columns )
Sets the columns to group by
Sets the columns to group by
Parameters
- $columns
mixed $columns The column (string) or columns (array) to group by
Returns
reference to this
|
public
reference
|
#
order( array $fields, mixed $escape = true )
Sets the fields to order by
Sets the fields to order by
Parameters
- $fields
array $fields The fields to order by
- $escape
Returns
reference to this
|
public
reference
|
#
limit( unsigned $records, unsigned $start = 0 )
Sets limits on the records of a query
Sets limits on the records of a query
Parameters
- $records
unsigned integer $records The number of records to retrieve
- $start
unsigned integer $start The record to start on (optional, default 0)
Returns
reference to this
|
public
mixed
|
#
fetch( )
Fetch a single row from the query
Fetch a single row from the query
Returns
mixed The return value on success depends on the fetch type. In all cases, false is
returned on failure.
See
|
public
mixed
|
#
fetchAll( )
Fetch all rows from the query
Fetch all rows from the query
Returns
mixed An array containing all of hte remaining rows in the result set, false on
failure.
See
|
public
PDOStatement
|
#
getStatement( )
Executes the query and returns the PDOStatment object
Executes the query and returns the PDOStatment object
Returns
PDOStatement
The executed statement object that may be iterated over
|
public
string
|
#
get( )
Converts the Record object to a query string. This differs from
Record::__toString() in that member variables are not restored to their state
prior to the method call, therefore this method may prove more useful when
constructing subqueries.
Converts the Record object to a query string. This differs from
Record::__toString() in that member variables are not restored to their state
prior to the method call, therefore this method may prove more useful when
constructing subqueries.
Returns
string The SQL query
See
|
public
string
|
#
__toString( )
Converts the Record object to a query string. This differs from Record::get()
in that member variables are restored to their state prior to the method
call.
Converts the Record object to a query string. This differs from Record::get()
in that member variables are restored to their state prior to the method
call.
Returns
string The SQL query
See
|
public
integer
|
#
numResults( )
Returns the number of results from the given query. This essentially wraps
the query into a new (sub) query, and returns a COUNT on that result
Returns the number of results from the given query. This essentially wraps
the query into a new (sub) query, and returns a COUNT on that result
Returns
integer The number of results from the given query
|
public
reference
|
#
open( )
Modifies the next where statement so that it beings with an open
parenthese
Modifies the next where statement so that it beings with an open
parenthese
Returns
reference to this
|
public
reference
|
#
close( string $conditional = "where" )
Modifies the given coditional statement to end with a close parenthese
Modifies the given coditional statement to end with a close parenthese
Parameters
- $conditional
string $conditional The conditional to close ("where", "on", "having", "duplicate")
Returns
reference to this
|
public
refe
|
#
appendValues( array $values )
Appends the given values to the values array so that they may be applied in
the given order.
Appends the given values to the values array so that they may be applied in
the given order.
Parameters
- $values
array $values An array of values to append to the existing array of values
Returns
refe to this
|
private
|
#
setFields( array $values, array $value_keys = null )
Set an array of values into this object to be used as paremeters in the
query
Set an array of values into this object to be used as paremeters in the
query
Parameters
- $values
array $values An array of values
- $value_keys
array $value_keys An array of key values to accept as valid fields
|
private
|
#
setConditional( string $conditional, array $statement )
Sets the conditional type and any necessary parentheses
Sets the conditional type and any necessary parentheses
Parameters
- $conditional
string $conditional The type: - where - on - having - duplicate
- $statement
array $statement The statement
|
private
string
|
#
buildConditionals( array $conditionals )
Consturctions a group of conditional statements as provided by the given
array of conditionals
Consturctions a group of conditional statements as provided by the given
array of conditionals
Parameters
- $conditionals
array $conditionals An array of conditional statements to construct into SQL
including: -field The field for the left hand side -op The operator used to join
the field and value -value The value of the right hand side -type The type of
conditional (optional: "or", "and", null = comma separated) -bind_value Whether
or not to bind the right hand value -escape Whether or not to escape the right
hand value
Returns
string The constructed SQL built using the given conditionals
|
private
string
|
#
buildConditional( string $field, string $op, mixed $value, boolean $bind_value = true, boolean $escape = true )
Constructs a conditional statement used in join, where, having, and on
duplicate clauses. Stores $value in $this->values array where possible.
Constructs a conditional statement used in join, where, having, and on
duplicate clauses. Stores $value in $this->values array where possible.
Parameters
- $field
string $field The field for comparison
- $op
string $op The operator to compare on
- $value
mixed $value The value to compare with
- $bind_value
boolean $bind_value True to treat $value as a bound value (i.e. a string or integer,
rather than an table or table field)
- $escape
boolean $escape True to escape the value, false otherwise
Returns
string The SQL that makes up this conditional statement
|
private
string
|
#
buildQuery( )
Builds a query
Returns
string The sql query
|
private
string
|
#
buildFields( boolean $create = true )
Builds all fields, keys, and indexes required when creating or altering a
table
Builds all fields, keys, and indexes required when creating or altering a
table
Parameters
- $create
boolean $create True if creating a table, false if altering
Returns
string A partial SQL query to be used when creating or altering a table
|
private
string
|
#
buildTableOptions( )
Builds the table options when creating a table
Builds the table options when creating a table
Returns
string The table options string
|
private
|
#
buildJoin( string $join, string $table, string $field = null, string $op = null, string $value = null, boolean $bind_value = true, boolean $escape = true )
Builds the given join statement
Builds the given join statement
Parameters
- $join
string $join The join type to use
- $table
string $table The table to join on
- $field
string $field The field for comparison
- $op
string $op The operator to compare on
- $value
string $value The value to compare with
- $bind_value
boolean $bind_value True to treat $value as a bound value (i.e. a string or integer,
rather than an table or table field)
- $escape
boolean $escape True to escape the value, false otherwise
|
private
string
|
#
buildColumns( )
Builds the columns of a query
Builds the columns of a query
Returns
string The columns to query
|
private
string
|
#
buildTables( )
Builds the tables to select from of a query
Builds the tables to select from of a query
Returns
string The tables to query
|
private
string
|
#
buildOnDuplicate( )
Builds the ON DUPLICATE KEY UPDATE clause of a query
Builds the ON DUPLICATE KEY UPDATE clause of a query
Returns
string The ON DUPLICATE KEY UPDATE clause of a query
|
private
string
|
#
buildWhere( )
Builds the WHERE clause of a query
Builds the WHERE clause of a query
Returns
string The WHERE clause of a query
|
private
string
|
#
buildOrder( )
Builds the ORDER BY clause of a query
Builds the ORDER BY clause of a query
Returns
string The ORDER BY clause of a query
|
private
string
|
#
buildGroup( )
Builds the GROUP BY clause of a query
Builds the GROUP BY clause of a query
Returns
string The GROUP BY clause of a query
|
private
string
|
#
buildHaving( )
Builds the HAVING clause of a query
Builds the HAVING clause of a query
Returns
string The HAVING clause of a query
|
private
string
|
#
buildLimit( )
Builds the LIMIT clause of a query
Builds the LIMIT clause of a query
Returns
string The LIMIT clause of a query
|
private
string
|
#
buildSubquery( array $subquery )
Builds the subquery as a given value, automatically wrapping with
parentheses
Builds the subquery as a given value, automatically wrapping with
parentheses
Parameters
- $subquery
array $subquery An array containing either the subquery string or a key/value pair of
subquery=>alias
Returns
string The subquery as a string (with optional AS alaising)
|
private
string
|
#
buildValues( )
Builds the field/value pairs of a query
Builds the field/value pairs of a query
Returns
string The field/value section of a query
|
private
string
|
#
buildValuePairs( mixed $pairs )
Creates key = value pairs, comma separated
Creates key = value pairs, comma separated
Returns
string The value pairs of a query
|
public
|
#
reset( )
Reset the object, making ready for the next query
Reset the object, making ready for the next query
|
private
string
|
#
escapeField( string $field )
Escapes a field or SQL function wrapped field. Supports name as well as
table.name as field formats
Escapes a field or SQL function wrapped field. Supports name as well as
table.name as field formats
Parameters
- $field
string $field The field to escape
Returns
string The escaped field
|
private
string
|
#
escapeFieldMatches( array $matches )
Escape an array of matched elements from Record::escapeField().
Escape an array of matched elements from Record::escapeField().
Parameters
- $matches
array $matches An array of matches from Record::escapeField()
Returns
string The escaped value
See
|
private
string
|
#
escapeTableField( string $field )
Escape field or table.field elements.
Escape field or table.field elements.
Parameters
- $field
string $field The field to escape in "field" or "table.field" format
Returns
string The escaped value
See
|
public
string
|
#
quoteIdentifier( mixed $identifier )
Escapes identifiers in the format of table.field or field, or an array of the
form array('table', 'field')
Escapes identifiers in the format of table.field or field, or an array of the
form array('table', 'field')
Parameters
- $identifier
mixed A string identifier or an array of identifier parts
Returns
string A string representing the quoted identifier
|