Class As_SelectQuery

Description

A simple SQL query object for SELECT statements.

Usage of this class in Cough allows for sharing base SQL so that less SQL code is copied and pasted amongst classes.

For example, if there is a Product object which has complicated SELECT SQL that joins into other tables, pulls extra data in the SELECT clause, includes a GROUP BY, and has default WHERE criteria like "is_retired = 0", then by using this you don't have to copy all those common parts into the all the collection static methods. Instead, they can share the base SQL and just add what they need. For example, to pull a single product one might do:

  1.      $sql Product::getLoadSql();
  2.      $sql->addWhere(array('product_id' => $productId));
  3.      echo $sql;

Another example might be pulling all products that have the same manufacturer ID:

  1.      Product_Collection::getProductsByManufacturer($manufId{
  2.          $sql Product::getLoadSql();
  3.          $sql->addWhere(array('manufacturer_id' => $manufId));
  4.          $collection new Product_Collection();
  5.          $collection->loadBySql($sql);
  6.          return $collection;
  7.      }

  • author: Anthony Bush

Located in /as_query/As_SelectQuery.class.php (line 37)

As_Query
   |
   --As_SelectQuery
Variable Summary
mixed $from
mixed $groupBy
mixed $having
mixed $limit
mixed $offset
mixed $orderBy
mixed $select
mixed $where
Method Summary
void addFrom ( $from)
void addGroupBy ( $groupBy)
void addHaving ( $having)
void addOrderBy ( $orderBy)
void addSelect ( $select)
void addWhere ( $where)
void getFrom ()
void getGroupBy ()
void getHaving ()
void getLimit ()
void getOffset ()
void getOrderBy ()
void getSelect ()
void getString ()
void getWhere ()
void setFrom ( $from)
void setGroupBy ( $groupBy)
void setHaving ( $having)
void setLimit ( $limit)
void setOffset ( $offset)
void setOrderBy ( $orderBy)
void setSelect ( $select)
void setWhere ( $where)
Variables
mixed $from = array() (line 40)
  • access: protected
mixed $groupBy = array() (line 42)
  • access: protected
mixed $having = array() (line 43)
  • access: protected
mixed $limit = '' (line 45)
  • access: protected
mixed $offset = '' (line 46)
  • access: protected
mixed $orderBy = array() (line 44)
  • access: protected
mixed $select = array() (line 39)
  • access: protected
mixed $where = array() (line 41)
  • access: protected

Inherited Variables

Inherited from As_Query

As_Query::$db
Methods
addFrom (line 107)
  • access: public
void addFrom ( $from)
  • $from
addGroupBy (line 127)
  • access: public
void addGroupBy ( $groupBy)
  • $groupBy
addHaving (line 137)
  • access: public
void addHaving ( $having)
  • $having
addOrderBy (line 147)
  • access: public
void addOrderBy ( $orderBy)
  • $orderBy
addSelect (line 97)
  • access: public
void addSelect ( $select)
  • $select
addWhere (line 117)
  • access: public
void addWhere ( $where)
  • $where
getClone (line 265)

Hack for versions of PHP that do not work with clone

  • author: Anthony Bush
  • since: 2008-03-17
  • access: public
As_SelectQuery getClone ()
getFrom (line 55)
  • access: public
void getFrom ()
getGroupBy (line 65)
  • access: public
void getGroupBy ()
getHaving (line 70)
  • access: public
void getHaving ()
getLimit (line 80)
  • access: public
void getLimit ()
getOffset (line 85)
  • access: public
void getOffset ()
getOrderBy (line 75)
  • access: public
void getOrderBy ()
getSelect (line 50)
  • access: public
void getSelect ()
getString (line 162)
  • access: public
void getString ()

Redefinition of:
As_Query::getString()
getWhere (line 60)
  • access: public
void getWhere ()
setFrom (line 102)
  • access: public
void setFrom ( $from)
  • $from
setGroupBy (line 122)
  • access: public
void setGroupBy ( $groupBy)
  • $groupBy
setHaving (line 132)
  • access: public
void setHaving ( $having)
  • $having
setLimit (line 152)
  • access: public
void setLimit ( $limit)
  • $limit
setOffset (line 157)
  • access: public
void setOffset ( $offset)
  • $offset
setOrderBy (line 142)
  • access: public
void setOrderBy ( $orderBy)
  • $orderBy
setSelect (line 92)
  • access: public
void setSelect ( $select)
  • $select
setWhere (line 112)
  • access: public
void setWhere ( $where)
  • $where

Inherited Methods

Inherited From As_Query

As_Query::__construct()
As_Query::add()
As_Query::buildWhereSql()
As_Query::execute()
As_Query::getEqualityOperatorFromValue()
As_Query::getInsertQuery()
As_Query::getSelectQuery()
As_Query::getString()
As_Query::getUpdateQuery()
As_Query::remapCriteria()
As_Query::run()
As_Query::setDb()
As_Query::__toString()

Documentation generated on Sun, 19 Oct 2008 11:56:30 -0500 by phpDocumentor 1.4.0