Class Zend_Db_Select

Description

Class for SQL SELECT generation and results.

  • license: New BSD License
  • copyright: Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com)

Located in /Zend/Db/Select.php (line 36)


	
			
Variable Summary
Method Summary
 Zend_Db_Select __construct (Zend_Db_Adapter_Abstract $adapter)
 Zend_Db_Select distinct ([bool $flag = true])
 Zend_Db_Select forUpdate ([bool $flag = true])
 Zend_Db_Select from (string $name, [array|string $cols = '*'])
 void group (string|array $spec)
 void having (string $cond, string $val)
 Zend_Db_Select join (string $name, string $cond, [array|string $cols = null])
 Zend_Db_Select joinInner (string $name, string $cond, [array|string $cols = null])
 Zend_Db_Select joinLeft (string $name, string $cond, [array|string $cols = null])
 void limit ([int $count = null], [int $offset = null])
 void limitPage (int $page, int $rowCount)
 void order (string|array $spec)
 void orHaving (string $cond, string $val)
 void orWhere (string $cond, string $val)
 void where (string $cond, string $val)
 Zend_Db_Select _join (null|string $type, string $name, string $cond, array|string $cols)
 void _tableCols (string $tbl, string|array $cols)
 string __toString ()
Variables
Zend_Db_Adapter_Abstract $_adapter (line 43)

Zend_Db_Adapter_Abstract object.

  • access: protected
array $_parts = array(
'distinct' => false,
'forUpdate' => false,
'cols' => array(),'from'=>array(),'join'=>array(),'where'=>array(),'group'=>array(),'having'=>array(),'order'=>array(),'limitCount'=>null,'limitOffset'=>null,)
(line 50)

The component parts of a SELECT statement.

  • access: protected
array $_tableCols = array() (line 69)

Tracks which columns are being select from each table and join.

  • access: protected
Methods
Constructor __construct (line 77)

Class constructor

  • access: public
Zend_Db_Select __construct (Zend_Db_Adapter_Abstract $adapter)
distinct (line 175)

Makes the query SELECT DISTINCT.

  • return: This Zend_Db_Select object.
  • access: public
Zend_Db_Select distinct ([bool $flag = true])
  • bool $flag: Whether or not the SELECT is DISTINCT (default true).
forUpdate (line 188)

Makes the query SELECT FOR UPDATE.

  • return: This Zend_Db_Select object.
  • access: public
Zend_Db_Select forUpdate ([bool $flag = true])
  • bool $flag: Whether or not the SELECT is DISTINCT (default true).
from (line 202)

Adds a FROM table and optional columns to the query.

  • return: This Zend_Db_Select object.
  • access: public
Zend_Db_Select from (string $name, [array|string $cols = '*'])
  • string $name: The table name.
  • array|string $cols: The columns to select from this table.
group (line 362)

Adds grouping to the query.

  • access: public
void group (string|array $spec)
  • string|array $spec: The column(s) to group by.
having (line 403)

Adds a HAVING condition to the query by AND.

If a value is passed as the second param, it will be quoted and replaced into the condition wherever a question-mark appears.

Array values are quoted and comma-separated.

  1.  // simplest but non-secure
  2.   $select->having("COUNT(id) = $count");
  3.  
  4.  // secure
  5.   $select->having('COUNT(id) = ?'$count);
  6.  
  7.  // equivalent security with named binding
  8.   $select->having('COUNT(id) = :count');
  9.  $select->bind('count'$count);

  • access: public
void having (string $cond, string $val)
  • string $cond: The HAVING condition.
  • string $val: A single value to quote into the condition.
join (line 253)

Adds a JOIN table and columns to the query.

  • return: This Zend_Db_Select object.
  • access: public
Zend_Db_Select join (string $name, string $cond, [array|string $cols = null])
  • string $name: The table name.
  • string $cond: Join on this condition.
  • array|string $cols: The columns to select from the joined table.
joinInner (line 280)

Add an INNER JOIN table and colums to the query

  • return: This Zend_Db_Select object.
  • access: public
Zend_Db_Select joinInner (string $name, string $cond, [array|string $cols = null])
  • string $name: The table name.
  • string $cond: Join on this condition.
  • array|string $cols: The columns to select from the joined table.
joinLeft (line 267)

Add a LEFT JOIN table and colums to the query

  • return: This Zend_Db_Select object.
  • access: public
Zend_Db_Select joinLeft (string $name, string $cond, [array|string $cols = null])
  • string $name: The table name.
  • string $cond: Join on this condition.
  • array|string $cols: The columns to select from the joined table.
limit (line 483)

Sets a limit count and offset to the query.

  • access: public
void limit ([int $count = null], [int $offset = null])
  • int $count: The number of rows to return.
  • int $offset: Start returning after this many rows.
limitPage (line 498)

Sets the limit and count by page number.

  • access: public
void limitPage (int $page, int $rowCount)
  • int $page: Limit results to this page number.
  • int $rowCount: Use this many rows per page.
order (line 454)

Adds a row order to the query.

  • access: public
void order (string|array $spec)
  • string|array $spec: The column(s) and direction to order by.
orHaving (line 431)

Adds a HAVING condition to the query by OR.

Otherwise identical to orHaving().

void orHaving (string $cond, string $val)
  • string $cond: The HAVING condition.
  • string $val: A single value to quote into the condition.
orWhere (line 339)

Adds a WHERE condition to the query by OR.

Otherwise identical to where().

void orWhere (string $cond, string $val)
  • string $cond: The WHERE condition.
  • string $val: A value to quote into the condition.
where (line 311)

Adds a WHERE condition to the query by AND.

If a value is passed as the second param, it will be quoted and replaced into the condition wherever a question-mark appears.

Array values are quoted and comma-separated.

  1.  // simplest but non-secure
  2.   $select->where("id = $id");
  3.  
  4.  // secure
  5.   $select->where('id = ?'$id);
  6.  
  7.  // equivalent security with named binding
  8.   $select->where('id = :id');
  9.  $select->bind('id'$id);

  • access: public
void where (string $cond, string $val)
  • string $cond: The WHERE condition.
  • string $val: A single value to quote into the condition.
_join (line 228)

Populate the $_parts 'join' key

Does the dirty work of populating the join key.

  • return: This Zend_Db_Select object
  • access: protected
Zend_Db_Select _join (null|string $type, string $name, string $cond, array|string $cols)
  • null|string $type: Type of join; inner, left, and null are currently supported
  • string $name: Table name
  • string $cond: Join on this condition
  • array|string $cols: The columns to select from the joined table
_tableCols (line 516)

Adds to the internal table-to-column mapping array.

  • access: protected
void _tableCols (string $tbl, string|array $cols)
  • string $tbl: The table/join the columns come from.
  • string|array $cols: The list of columns; preferably as an array, but possibly as a comma-separated string.
__toString (line 88)

Converts this object to an SQL SELECT string.

  • return: This object as a SELECT string.
  • access: public
string __toString ()

Documentation generated on Fri, 30 Jun 2006 11:21:36 -0500 by phpDocumentor 1.3.0RC6