PHP Class SQLSelectClause

Afficher le fichier Open project: sourcefabric/newscoop Class Usage Examples

Méthodes publiques

Méthode Description
__construct ( $p_indent ) Class constructor
addColumn ( string $p_column ) : void Adds a column to be fetched by the query.
addConditionalWhere ( string $p_condition ) : void Adds a conditional WHERE condition to the query (using 'OR' operator)
addGroupField ( $p_field ) Add group field
addHaving ( $p_condition ) Add HAVING condition
addJoin ( string $p_join ) : void Adds a table join to the query.
addOrderBy ( string $p_order ) : void Adds an ORDER BY condition to the query.
addTableFrom ( string $p_table ) : void Adds a table to the FROM part of the query.
addWhere ( string $p_condition ) : void Adds a WHERE condition to the query.
buildQuery ( ) : string Builds the SQL query from the object attributes.
setDistinct ( string $p_column = null ) : void Sets all or specific column(s) to be fetched DISTINCT.
setLimit ( integer $p_start, integer $p_offset ) : void Sets the LIMIT of the query.
setTable ( string $p_table ) : void Sets the name of the main table in the query.

Private Methods

Méthode Description
buildColumns ( ) : string Builds the list of columns to be retrieved by the query.
buildFrom ( ) : string Builds the FORM part of the query based on the main table and whether there is some table to join with.
buildGroupBy ( ) : string Builds the GROUP BY clause.
buildHaving ( ) : string Builds the HAVING clause.
buildOrderBy ( ) : string Builds the ORDER BY conditions.
buildWhere ( ) : string Builds the list of WHERE conditions.
hasFrom ( ) : boolean Returns whether there is FROM tables other than the main query table.
hasJoins ( ) : boolean Returns whether there is table joins.
indent ( $p_inner ) : string Returns the indentation string

Method Details

__construct() public méthode

Class constructor
public __construct ( $p_indent )

addColumn() public méthode

Adds a column to be fetched by the query.
public addColumn ( string $p_column ) : void
$p_column string The name of the column
Résultat void

addConditionalWhere() public méthode

Adds a conditional WHERE condition to the query (using 'OR' operator)
public addConditionalWhere ( string $p_condition ) : void
$p_condition string The comparison operation
Résultat void

addGroupField() public méthode

Add group field
public addGroupField ( $p_field )
$p_field

addHaving() public méthode

Add HAVING condition
public addHaving ( $p_condition )
$p_condition

addJoin() public méthode

Adds a table join to the query.
public addJoin ( string $p_join ) : void
$p_join string The full join string including the ON condition
Résultat void

addOrderBy() public méthode

Adds an ORDER BY condition to the query.
public addOrderBy ( string $p_order ) : void
$p_order string The column and the direction of the order condition
Résultat void

addTableFrom() public méthode

Adds a table to the FROM part of the query.
public addTableFrom ( string $p_table ) : void
$p_table string The name of the table
Résultat void

addWhere() public méthode

Adds a WHERE condition to the query.
public addWhere ( string $p_condition ) : void
$p_condition string The comparison operation
Résultat void

buildQuery() public méthode

Builds the SQL query from the object attributes.
public buildQuery ( ) : string
Résultat string $sql The full SQL query

setDistinct() public méthode

Sets all or specific column(s) to be fetched DISTINCT.
public setDistinct ( string $p_column = null ) : void
$p_column string The column which have to fetched distinct
Résultat void

setLimit() public méthode

Sets the LIMIT of the query.
public setLimit ( integer $p_start, integer $p_offset ) : void
$p_start integer The number where the query will start to fetch data
$p_offset integer The number of rows to be fetched
Résultat void

setTable() public méthode

Sets the name of the main table in the query.
public setTable ( string $p_table ) : void
$p_table string The name of the table
Résultat void