Makes the query SELECT DISTINCT.
-
bool
$flag: Whether or not the SELECT is DISTINCT (default true).
Makes the query SELECT FOR UPDATE.
-
bool
$flag: Whether or not the SELECT is DISTINCT (default true).
Adds a FROM table and optional columns to the query.
-
string
$name: The table name.
-
array|string
$cols: The columns to select from this table.
Adds grouping to the query.
void
group
(string|array $spec)
-
string|array
$spec: The column(s) to group by.
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. See where() for an example
void
having
(string $cond, string $val)
-
string
$cond: The HAVING condition.
-
string
$val: A single value to quote into the condition.
Adds a JOIN table and columns to the query.
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.
Add an INNER JOIN table and colums to the query
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.
Add a LEFT JOIN table and colums to the query
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.
Sets a limit count and offset to the query.
void
limit
([int $count = null], [int $offset = null])
-
int
$count: The number of rows to return.
-
int
$offset: Start returning after this many rows.
Sets the limit and count by page number.
void
limitPage
(int $page, int $rowCount)
-
int
$page: Limit results to this page number.
-
int
$rowCount: Use this many rows per page.
Adds a row order to the query.
void
order
(string|array $spec)
-
string|array
$spec: The column(s) and direction to order by.
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.
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.
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.
// simplest but non-secure
$select->where("id = $id");
// secure (ID is quoted but matched anyway)
$select->where('id = ?', $id);
// alternatively, with named binding
$select->where('id = :id');
Note that it is more correct to use named bindings in your queries for values other than strings. When you use named bindings, don't forget to pass the values when actually making a query:
$db->fetchAll($select, array('id' => 5));
void
where
(string $cond, string $val)
-
string
$cond: The WHERE condition.
-
string
$val: A single value to quote into the condition.
Populate the $_parts 'join' key
Does the dirty work of populating the join key.
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
Adds to the internal table-to-column mapping array.
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.
Converts this object to an SQL SELECT string.
string
__toString
()