Class Zend_Db_Select

Description

Class for SQL SELECT generation and results.

  • license: Zend
  • copyright: Copyright (c) 2005-2006 Zend Technologies Inc. (http://www.zend.com)

Located in /library/Zend/Db/Select.php (line 34)


	
			
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 41)

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 48)

The component parts of a SELECT statement.

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

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

  • access: protected
Methods
Constructor __construct (line 75)

Class constructor

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

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 186)

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 200)

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 360)

Adds grouping to the query.

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

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 251)

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 278)

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 265)

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 481)

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 496)

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 452)

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 429)

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 337)

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 309)

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 226)

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 514)

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 86)

Converts this object to an SQL SELECT string.

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

Documentation generated on Wed, 08 Mar 2006 04:54:47 -0800 by phpDocumentor 1.3.0RC4