Source for file SelectQuery.interface.php

Documentation is available at SelectQuery.interface.php

  1. <?php
  2. /**
  3. * @package harmoni.dbc
  4. *
  5. * @copyright Copyright &copy; 2005, Middlebury College
  6. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  7. *
  8. * @version $Id: SelectQuery.interface.php,v 1.9 2007/09/05 21:38:59 adamfranco Exp $
  9. */
  10.  
  11. require_once("Query.abstract.php");
  12.  
  13. /**
  14. * Used with the setTable() method to indicate that no join will be performed.
  15. * @const NO_JOIN No join will be performed.
  16. */
  17. define("NO_JOIN", 1);
  18.  
  19. /**
  20. * Used with the setTable() method to indicate that a left join will be performed.
  21. * @const LEFT_JOIN A left join will be performed.
  22. */
  23. define("LEFT_JOIN", 2);
  24.  
  25. /**
  26. * Used with the setTable() method to indicate that an inner join will be performed.
  27. * @const INNER_JOIN An inner join will be performed.
  28. */
  29. define("INNER_JOIN", 3);
  30.  
  31. /**
  32. * Used with the setTable() method to indicate that a right join will be performed.
  33. * @const RIGHT_JOIN A right join will be performed.
  34. */
  35. define("RIGHT_JOIN", 4);
  36.  
  37. /**
  38. * Used with the setOrderBy() method to indicate that the order will be ascending. Used by {@link SelectQueryInterface::setOrderBy()}.
  39. * @const ASCENDING The order will be ascending.
  40. */
  41. define("ASCENDING", 5);
  42.  
  43. /**
  44. * Used with the setOrderBy() method to indicate that the order will be descending. Used by {@link SelectQueryInterface::setOrderBy()}.
  45. * @const DESCENDING The order will be descending.
  46. */
  47. define("DESCENDING", 6);
  48.  
  49.  
  50. /**
  51. * A SelectQuery interface provides the tools to build an SQL SELECT query.
  52. *
  53. *
  54. * @package harmoni.dbc
  55. *
  56. * @copyright Copyright &copy; 2005, Middlebury College
  57. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  58. *
  59. * @version $Id: SelectQuery.interface.php,v 1.9 2007/09/05 21:38:59 adamfranco Exp $
  60. */
  61.  
  62. interface SelectQueryInterface
  63. extends Query
  64. {
  65.  
  66. /**
  67. * Adds a table to the FROM clause of the SELECT query.
  68. *
  69. * Adds a table to the FROM clause of the SELECT statement. At any moment,
  70. * a current set of tables is maintained in the object, so when a new one
  71. * is added, it is combined with the current set.
  72. * @param string $table The table to add to the FROM clause.
  73. * @param integer $joinType Specifies what type of join to perform between
  74. * the current set of tables and the table being added. Could be one of
  75. * the following: NO_JOIN, LEFT_JOIN, INNER_JOIN, RIGHT_JOIN.
  76. * @param string $joinCondition If a join is to be performed, then this
  77. * will indicate the join condition.
  78. * @param string alias An alias for this table.
  79. * @use NO_JOIN
  80. * @use LEFT_JOIN
  81. * @use INNER_JOIN
  82. * @use RIGHT_JOIN
  83. * @access public
  84. */
  85. function addTable($table, $joinType = NO_JOIN, $joinCondition = "", $alias = "") ;
  86.  
  87. /**
  88. /**
  89. * *Deprecated* Sets the columns to select.
  90. * Sets the columns to select.
  91. * Note: addColumn() and setColumns() can be used together in any order.
  92. * However, calling setColumns() after addColumn() resets the list of columns.
  93. * @param array $column The columns to select. This is a one-dimensional array
  94. * of the column names. If you want aliases you have to include the alias
  95. * in the column name itself. For example: array("user_id AS id", "user_name AS name")
  96. * For a better approach, see addColumn().
  97. * @access public
  98. * @deprecated June 24, 2003 - Use addColumn() instead.
  99. * @see SelectQueryInterface::addColumn()
  100. */
  101. function setColumns($columns) ;
  102. /**
  103. /**
  104. * Adds a new column to the SELECT query.
  105. * Adds a new column to the SELECT query. This method is an alternative to the
  106. * setColumns() method. It adds one column at a time, and also provides
  107. * the ability to explicitly specify the alias of the column to select.
  108. * Note: addColumn() and setColumns() can be used together in any order.
  109. * However, calling setColumns() after addColumn() resets the list of columns.
  110. * @param string $column The name of the column.
  111. * @param optional string $alias The alias of the column.
  112. * @param optional string $table An optional name of the table where
  113. * the column resides.
  114. * will be used.
  115. * @access public
  116. * @see SelectQueryInterface::setColumns()
  117. */
  118. function addColumn($column, $alias = "", $table = "") ;
  119.  
  120.  
  121. /**
  122. /**
  123. * *Deprecated* Specifies the condition in the WHERE clause.
  124. *
  125. * The query will return only rows that fulfil the condition. If this method
  126. * is never called, then the WHERE clause will not be included.
  127. * @param string condition The WHERE clause condition.
  128. * @deprecated July 07, 2003 - Use addWhere() instead.
  129. * @access public
  130. */
  131. function setWhere($condition) ;
  132. /**
  133. /**
  134. * Adds a new condition in the WHERE clause.
  135. *
  136. * The query will return only rows that fulfil the condition. If this method
  137. * is never called, then the WHERE clause will not be included.
  138. * @param string condition The WHERE clause condition to add.
  139. * @param integer logicalOperation The logical operation to use to connect
  140. * this WHERE condition with the previous WHERE conditions. Allowed values:
  141. * <code>_AND</code> and <code>_OR</code>.
  142. * @access public
  143. * @return void
  144. */
  145. function addWhere($condition, $logicalOperation = _AND) ;
  146. /**
  147. /**
  148. * Resets the WHERE clause.
  149. * @access public
  150. ***/
  151. function resetWhere() ;
  152.  
  153. /**
  154. /**
  155. * Sets the GROUP BY and HAVING clause.
  156. *
  157. * This method sets the GROUP BY clause of the SELECT statement. In addition,
  158. * if $condition is specified, it includes the HAVING clause. If the method is never
  159. * called, no GROUP BY or HAVING clause will be included.
  160. * @param array $columns An array of the columns to group by. Ideally, the
  161. * columns should be in the list provided by setColumns().
  162. * @param string $condition An optional condition to be included in the
  163. * HAVING clause.
  164. * @access public
  165. */
  166. function setGroupBy($columns, $condition = "") ;
  167.  
  168. /**
  169. /**
  170. * Add a column to the ORDER BY clause.
  171. *
  172. * This method adds a column to the ORDER BY clause of the SELECT statement. If the method is never
  173. * called, no ORDER BY clause will be included. The order of the columns in the
  174. * clause will coincide with the order, in which they were added with this method.
  175. * @param string $column A column to order by.
  176. * @param integer $direction An optional parameter specifying ascending or descending
  177. * sorting order. Allowed values are: ASCENDING, DESCENDING.
  178. * @use ASCENDING
  179. * @use DESCENDING
  180. * @access public
  181. */
  182. function addOrderBy($column, $direction = ASCENDING) ;
  183. /**
  184. /**
  185. * Specifies whether distinct rows will be returned.
  186. *
  187. * Use this method to specify whether the rows returned by the SELECT query
  188. * have to be distinct (i.e. only unique rows) or not. If the method is never
  189. * called, then the default value is not distinct.
  190. * @param boolean $distinct If true, then only unique rows will be returned.
  191. * @access public
  192. */
  193. function setDistinct($distinct) ;
  194. /**
  195. /**
  196. * Limits the number of rows to the specified number.
  197. *
  198. * Limits the number of rows returned by the SELECT query to the specified
  199. * number.
  200. * @param integer $numberOfRows The number of rows to return
  201. * @access public
  202. */
  203. function limitNumberOfRows($numberOfRows) ;
  204. /**
  205. /**
  206. * Starts the results from the specified row.
  207. *
  208. * Starts the results of the SELECT query from the specified row.
  209. * @param integer $startingRow The number of the starting row. Numbers
  210. * start with 1 for the first row, 2 for the second row, and so forth.
  211. * @access public
  212. */
  213. function startFromRow($startFromRow) ;
  214.  
  215. ?>

Documentation generated on Wed, 19 Sep 2007 10:26:23 -0400 by phpDocumentor 1.3.0RC3