Public Member Functions | Static Public Member Functions | Public Attributes | Protected Attributes

Query Class Reference

List of all members.

Public Member Functions

 __construct ($primary_table=null)
 select ($fields)
 set_select ($fields)
 distinct ($set=true)
 from ($primary_table)
 join ($join, $parameters=array(), $alias=null)
 joined ($alias)
 where ($operator= 'AND')
 groupby ($value)
 orderby ($value)
 having ($value)
 limit ($value)
 offset ($value)
 get ()
 params ()
 row ($class=null)
 results ($class=null)
 keyvalue ()
 column ()
 value ()

Static Public Member Functions

static create ($primary_table=null)
static new_param_name ($prefix= 'param')

Public Attributes

 $primary_table = null

Protected Attributes

 $fields = array()
 $joins = array()
 $join_params = array()
 $limit = null
 $offset = null
 $orderby = null
 $groupby = null
 $having = null

Detailed Description

Base Query class for building new queries

See also:
Posts::get

Definition at line 9 of file query.php.


Member Function Documentation

Query::column (  ) 

Execute and return the first first field from each row of this query

Returns:
array The result array of values

Definition at line 317 of file query.php.

Query::distinct ( set = true  ) 

Set whether only distinct results should be returned

Parameters:
bool $set True if the result set should be distinct
Returns:
Query Returns $this for fluid interface

Definition at line 77 of file query.php.

Referenced by get().

Query::from ( primary_table  ) 

Sets the primary table for the FROM statement

Parameters:
string $primary_table The primary table from which to select
Returns:
Query Returns $this for fluid interface

Definition at line 88 of file query.php.

Query::get (  ) 

Obtain the SQL used to execute this query

Returns:
string The SQL to execute

Definition at line 188 of file query.php.

Referenced by QueryWhere::exists().

Query::groupby ( value  ) 

Set the GROUP BY clause

Parameters:
string $value The GROUP BY clause
Returns:
Query Returns $this for fluid interface

Definition at line 139 of file query.php.

Referenced by get().

Query::join ( join,
parameters = array(),
alias = null 
)

Adds a JOIN table

Parameters:
string $join The table to create a join with
array $parameters An array of parameters on which the JOIN is built
string $alias An optional alias for the joined table
Returns:
Query Returns $this for fluid interface

Definition at line 101 of file query.php.

Query::joined ( alias  ) 

Discover if a table alias is already JOINed to this query

Parameters:
string $alias The name of a JOIN table alias
Returns:
bool true if the alias was used for a join

Definition at line 116 of file query.php.

Query::keyvalue (  ) 

Execute and return key-value pairs from this query

Returns:
array The results array of QueryRecords or the specified class

Definition at line 308 of file query.php.

Query::limit ( value  ) 

Sets the LIMIT

Parameters:
integer $value The LIMIT
Returns:
Query Returns $this for fluid interface

Definition at line 167 of file query.php.

Referenced by get().

static Query::new_param_name ( prefix = 'param'  )  [static]

Obtain a parameter name with an optionally specified prefix that has not yet been used

Parameters:
string $prefix An optional prefix to use for a new parameter
Returns:
string the new parameter

Definition at line 273 of file query.php.

Referenced by Posts::get(), and QueryWhere::in().

Query::offset ( value  ) 

Sets the OFFSET

Parameters:
integer $value The OFFSET
Returns:
Query Returns $this for fluid interface

Definition at line 178 of file query.php.

Referenced by get().

Query::orderby ( value  ) 

Set the ORDER BY clause

Parameters:
string $value The ORDER BY clause
Returns:
Query Returns $this for fluid interface

Definition at line 150 of file query.php.

Referenced by get().

Query::params (  ) 

Obtain the parameter values needed for the query

Returns:
array An associative array containing the parameters of the query

Definition at line 262 of file query.php.

Referenced by column(), QueryWhere::exists(), keyvalue(), results(), row(), and value().

Query::results ( class = null  ) 

Execute and return the returns of this query

Parameters:
string $class The optional class to return results as
Returns:
array The results array of QueryRecords or the specified class

Definition at line 299 of file query.php.

Query::row ( class = null  ) 

Execute and return the first row of this query

Parameters:
string $class The optional class to return results as
Returns:
object The result object, a QueryRecord or the specified class

Definition at line 289 of file query.php.

Query::select ( fields  ) 

Adds fields to the SELECT statement

Parameters:
array|string $fields A field or list of fields to add to existing select'ed fields
Returns:
Query Returns $this for fluid interface

Definition at line 52 of file query.php.

Query::set_select ( fields  ) 

Sets fields for the SELECT statement

Parameters:
array|string $fields A field or list of fields to set as the fields to select, replaces existing selected fields
Returns:
Query Returns $this for fluid interface

Definition at line 66 of file query.php.

Query::value (  ) 

Execute and return the first row of this query

Returns:
object The result object, a QueryRecord or the specified class

Definition at line 326 of file query.php.

Query::where ( operator = 'AND'  ) 

Create and/or return a QueryWhere object representing the where clause of this query

Parameters:
string $operator The operator (AND/OR) to use between expressions in this clause
Returns:
QueryWhere An instance of the where clause for this query

Definition at line 126 of file query.php.

Referenced by get(), and params().


The documentation for this class was generated from the following file: