PHP Класс SQLSelectClause

Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
__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.

Приватные методы

Метод Описание
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

Описание методов

__construct() публичный Метод

Class constructor
public __construct ( $p_indent )

addColumn() публичный Метод

Adds a column to be fetched by the query.
public addColumn ( string $p_column ) : void
$p_column string The name of the column
Результат void

addConditionalWhere() публичный Метод

Adds a conditional WHERE condition to the query (using 'OR' operator)
public addConditionalWhere ( string $p_condition ) : void
$p_condition string The comparison operation
Результат void

addGroupField() публичный Метод

Add group field
public addGroupField ( $p_field )
$p_field

addHaving() публичный Метод

Add HAVING condition
public addHaving ( $p_condition )
$p_condition

addJoin() публичный Метод

Adds a table join to the query.
public addJoin ( string $p_join ) : void
$p_join string The full join string including the ON condition
Результат void

addOrderBy() публичный Метод

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
Результат void

addTableFrom() публичный Метод

Adds a table to the FROM part of the query.
public addTableFrom ( string $p_table ) : void
$p_table string The name of the table
Результат void

addWhere() публичный Метод

Adds a WHERE condition to the query.
public addWhere ( string $p_condition ) : void
$p_condition string The comparison operation
Результат void

buildQuery() публичный Метод

Builds the SQL query from the object attributes.
public buildQuery ( ) : string
Результат string $sql The full SQL query

setDistinct() публичный Метод

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
Результат void

setLimit() публичный Метод

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
Результат void

setTable() публичный Метод

Sets the name of the main table in the query.
public setTable ( string $p_table ) : void
$p_table string The name of the table
Результат void