Interface SelectQueryInterface

Description

A SelectQuery interface provides the tools to build an SQL SELECT query.

  • version: $Id: SelectQuery.interface.php,v 1.9 2007/09/05 21:38:59 adamfranco Exp $
  • license: GNU General Public License (GPL)
  • copyright: Copyright © 2005, Middlebury College

Located in /harmoni/core/DBHandler/SelectQuery.interface.php (line 62)

Query
   |
   --SelectQueryInterface
Method Summary
void addColumn (string $column, [optional $alias = ""], [optional $table = ""])
void addOrderBy (string $column, [integer $direction = ASCENDING])
void addTable (string $table, [integer $joinType = NO_JOIN], [string $joinCondition = ""], [string $alias = ""])
void addWhere (string $condition, [integer $logicalOperation = _AND])
void limitNumberOfRows (integer $numberOfRows)
void resetWhere ()
void setColumns (mixed $columns, array $column)
void setDistinct (boolean $distinct)
void setGroupBy (array $columns, [string $condition = ""])
void setWhere (string $condition)
void startFromRow (mixed $startFromRow, integer $startingRow)
Methods
addColumn (line 119)

Adds a new column to the SELECT query.

Adds a new column to the SELECT query. This method is an alternative to the setColumns() method. It adds one column at a time, and also provides the ability to explicitly specify the alias of the column to select. Note: addColumn() and setColumns() can be used together in any order. However, calling setColumns() after addColumn() resets the list of columns.

void addColumn (string $column, [optional $alias = ""], [optional $table = ""])
  • string $column: The name of the column.
  • optional $alias: string $alias The alias of the column.
  • optional $table: string $table An optional name of the table where the column resides. will be used.
addOrderBy (line 184)

Add a column to the ORDER BY clause.

This method adds a column to the ORDER BY clause of the SELECT statement. If the method is never called, no ORDER BY clause will be included. The order of the columns in the clause will coincide with the order, in which they were added with this method.

  • access: public
void addOrderBy (string $column, [integer $direction = ASCENDING])
  • string $column: A column to order by.
  • integer $direction: An optional parameter specifying ascending or descending sorting order. Allowed values are: ASCENDING, DESCENDING.
addTable (line 85)

Adds a table to the FROM clause of the SELECT query.

Adds a table to the FROM clause of the SELECT statement. At any moment, a current set of tables is maintained in the object, so when a new one is added, it is combined with the current set.

  • access: public
void addTable (string $table, [integer $joinType = NO_JOIN], [string $joinCondition = ""], [string $alias = ""])
  • string $table: The table to add to the FROM clause.
  • integer $joinType: Specifies what type of join to perform between the current set of tables and the table being added. Could be one of the following: NO_JOIN, LEFT_JOIN, INNER_JOIN, RIGHT_JOIN.
  • string $joinCondition: If a join is to be performed, then this will indicate the join condition.
  • string $alias: alias An alias for this table.
addWhere (line 147)

Adds a new condition in the WHERE clause.

The query will return only rows that fulfil the condition. If this method is never called, then the WHERE clause will not be included.

  • access: public
void addWhere (string $condition, [integer $logicalOperation = _AND])
  • string $condition: condition The WHERE clause condition to add.
  • integer $logicalOperation: logicalOperation The logical operation to use to connect this WHERE condition with the previous WHERE conditions. Allowed values:
    1. _AND
    and
    1. _OR
    .
limitNumberOfRows (line 206)

Limits the number of rows to the specified number.

Limits the number of rows returned by the SELECT query to the specified number.

  • access: public
void limitNumberOfRows (integer $numberOfRows)
  • integer $numberOfRows: The number of rows to return
resetWhere (line 154)

Resets the WHERE clause.

  • access: public
void resetWhere ()
setColumns (line 100)

*Deprecated* Sets the columns to select.

Sets the columns to select. Note: addColumn() and setColumns() can be used together in any order. However, calling setColumns() after addColumn() resets the list of columns.

void setColumns (mixed $columns, array $column)
  • array $column: The columns to select. This is a one-dimensional array of the column names. If you want aliases you have to include the alias in the column name itself. For example: array("user_id AS id", "user_name AS name") For a better approach, see addColumn().
setDistinct (line 195)

Specifies whether distinct rows will be returned.

Use this method to specify whether the rows returned by the SELECT query have to be distinct (i.e. only unique rows) or not. If the method is never called, then the default value is not distinct.

  • access: public
void setDistinct (boolean $distinct)
  • boolean $distinct: If true, then only unique rows will be returned.
setGroupBy (line 169)

Sets the GROUP BY and HAVING clause.

This method sets the GROUP BY clause of the SELECT statement. In addition, if $condition is specified, it includes the HAVING clause. If the method is never called, no GROUP BY or HAVING clause will be included.

  • access: public
void setGroupBy (array $columns, [string $condition = ""])
  • array $columns: An array of the columns to group by. Ideally, the columns should be in the list provided by setColumns().
  • string $condition: An optional condition to be included in the HAVING clause.
setWhere (line 132)

*Deprecated* Specifies the condition in the WHERE clause.

The query will return only rows that fulfil the condition. If this method is never called, then the WHERE clause will not be included.

  • access: public
  • deprecated: July 07, 2003 - Use addWhere() instead.
void setWhere (string $condition)
  • string $condition: condition The WHERE clause condition.
startFromRow (line 218)

Starts the results from the specified row.

Starts the results of the SELECT query from the specified row.

  • access: public
void startFromRow (mixed $startFromRow, integer $startingRow)
  • integer $startingRow: The number of the starting row. Numbers start with 1 for the first row, 2 for the second row, and so forth.

Inherited Methods

Inherited From Query

Query::getType()
Query::reset()

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