soo_txp_obj API Documentation

soo_txp_query Class Reference

Abstract base class for SQL queries. More...

List of all members.

Public Member Functions

 __construct ($table, $key=null)
 Constructor.
 where ($column, $value, $operator= '=', $join= '')
 Add expression to WHERE clause.
 where_clause ($clause, $join= '')
 Add a raw expression to WHERE clause.
 in ($column, $list, $join= '', $in=true)
 Add an IN expression to the WHERE clause.
 not_in ($column, $list, $join= '')
 Alias of in() with $in = false (add a NOT IN expression).
 regexp ($pattern, $subject, $join= '')
 Add a MySQL REGEXP expression to the WHERE clause.
 order_by ($expr, $direction= '')
 Add an expression to the ORDER BY array.
 asc ($col)
 Alias of order_by() for a single column ASC.
 desc ($col)
 Alias of order_by() for a single column DESC.
 order_by_field ($field, $list)
 Add a FIELD() expression to the ORDER BY array.
 limit ($limit)
 Add a LIMIT to the query.
 offset ($offset)
 Add an OFFSET to the query.
 count ()
 Number of items the query will return.
 key_column ($key_value=null)
 Return the key column name for the current table.

Static Public Member Functions

static quote ($identifier)
 Quote with backticks.

Protected Member Functions

 andor ($join= 'and')
 clause_string ()
 Assemble and return the query clauses as a string.

Protected Attributes

 $table = ''
 Database table name.
 $where = array()
 SQL WHERE expressions.
 $order_by = array()
 SQL ORDER BY expressions.
 $limit = 0
 SQL LIMIT.
 $offset = 0
 SQL OFFSET.

Detailed Description

Abstract base class for SQL queries.

Definition at line 82 of file soo_txp_obj.php.


Constructor & Destructor Documentation

soo_txp_query::__construct ( table,
key = null 
)

Constructor.

Use $key to match a single row matching on appropriate key column If $key is an array, current key is the column and current value is the value. Otherwise column will be taken from self::key_column().

Parameters:
table Table name
key Key column value (or array) for WHERE expression

Reimplemented in soo_txp_upsert.

Definition at line 102 of file soo_txp_obj.php.


Member Function Documentation

soo_txp_query::asc ( col  ) 

Alias of order_by() for a single column ASC.

Parameters:
col Column name

Definition at line 226 of file soo_txp_obj.php.

soo_txp_query::clause_string (  )  [protected]

Assemble and return the query clauses as a string.

Returns:
string

Definition at line 277 of file soo_txp_obj.php.

soo_txp_query::count (  ) 

Number of items the query will return.

Runs the query with COUNT() as the select expression

Returns:
int|false

Reimplemented in soo_txp_left_join.

Definition at line 288 of file soo_txp_obj.php.

soo_txp_query::desc ( col  ) 

Alias of order_by() for a single column DESC.

Parameters:
col Column name

Definition at line 234 of file soo_txp_obj.php.

soo_txp_query::in ( column,
list,
join = '',
in = true 
)

Add an IN expression to the WHERE clause.

Parameters:
column Column name
list Items to compare against
join AND or OR
in true = IN, false = NOT IN

Definition at line 151 of file soo_txp_obj.php.

soo_txp_query::key_column ( key_value = null  ) 

Return the key column name for the current table.

Some Txp tables have multiple indexes. If $key_value is provided, column of the matching type will be returned. Otherwise the numeric index will be returned in preference to the string index.

Parameters:
key_value 
Returns:
string

Definition at line 300 of file soo_txp_obj.php.

soo_txp_query::limit ( limit  ) 

Add a LIMIT to the query.

Parameters:
limit Maximum number of items to return

Definition at line 257 of file soo_txp_obj.php.

soo_txp_query::not_in ( column,
list,
join = '' 
)

Alias of in() with $in = false (add a NOT IN expression).

Parameters:
column Column name
list Items to compare against
join AND or OR

Definition at line 164 of file soo_txp_obj.php.

soo_txp_query::offset ( offset  ) 

Add an OFFSET to the query.

Parameters:
offset Number of items to skip

Definition at line 267 of file soo_txp_obj.php.

soo_txp_query::order_by ( expr,
direction = '' 
)

Add an expression to the ORDER BY array.

Example: $query->order_by('foo ASC, bar DESC');

Parameters:
expr Comma-separated list, or array, of expressions
direction ASC or DESC

Reimplemented in soo_txp_left_join.

Definition at line 202 of file soo_txp_obj.php.

soo_txp_query::order_by_field ( field,
list 
)

Add a FIELD() expression to the ORDER BY array.

For preserving an arbitrary sort order, e.g. '7,5,12,1' Note that FIELD() is a MySQL-specific function (not standard SQL)

Parameters:
field Column name
list Comma-separated list, or array, of values in order

Definition at line 245 of file soo_txp_obj.php.

static soo_txp_query::quote ( identifier  )  [static]

Quote with backticks.

Only quote items consisting of alphanumerics, $, and/or _

Parameters:
identifier Item to quote
Returns:
string

Definition at line 191 of file soo_txp_obj.php.

soo_txp_query::regexp ( pattern,
subject,
join = '' 
)

Add a MySQL REGEXP expression to the WHERE clause.

Parameters:
pattern MySQL REGEXP pattern
subject Column name or string to match
join AND or OR

Definition at line 174 of file soo_txp_obj.php.

soo_txp_query::where ( column,
value,
operator = '=',
join = '' 
)

Add expression to WHERE clause.

Parameters:
column Column name
value Column value(s) (string, array, or soo_txp_select)
operator Comparison operator
join AND or OR

Reimplemented in soo_txp_left_join.

Definition at line 117 of file soo_txp_obj.php.

soo_txp_query::where_clause ( clause,
join = '' 
)

Add a raw expression to WHERE clause.

Use instead of where() for complex (e.g. nested) expressions

Parameters:
clause WHERE Expression
join AND or OR

Definition at line 138 of file soo_txp_obj.php.


The documentation for this class was generated from the following file:
 All Classes Functions Variables