PHP Класс SqlBuilder, recess

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

Защищенные свойства (Protected)

Свойство Тип Описание
$assignments
$conditions * UPDATE & DELETE
$conditionsUsed
$distinct
$groupBy
$joins
$limit
$offset
$orderBy
$select * SELECT
$selectAs
$table * INSERT
$useAssignmentsAsConditions
$usingAliases

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

Метод Описание
assign ( string $column, mixed $value ) : SqlBuilder Assign a value to a column. Used with inserts and updates.
between ( string $column, numeric $small, numeric $big ) : SqlBuilder Shortcut alias for SqlBuilder->lessThan($column,$big)->greaterThan($column,$small)
delete ( ) : string Build a DELETE SQL string from SqlBuilder's state.
distinct ( ) : SqlBuilder Add a DISTINCT clause to SELECT SQL.
equal ( string $column, mixed $value ) : SqlBuilder Equality expression for WHERE clause of update, delete, or select statements.
from ( string $table ) : SqlBuilder Alias to specify which table is being used.
getCriteria ( )
getPdoArguments ( ) : array Return the collection of PDO named parameters and values to be applied to a parameterized PDO statement.
getTable ( )
greaterThan ( string $column, numeric $value ) : SqlBuilder Greater than expression for WHERE clause of update, delete, or select statements.
greaterThanOrEqualTo ( string $column, numeric $value ) : SqlBuilder Greater than or equal to expression for WHERE clause of update, delete, or select statements.
groupBy ( string $clause ) : SqlBuilder Add an GROUP BY expression to sql string. Example: ->groupBy('name')
in ( string $column, array $value ) : SqlBuilder IN to expression for WHERE clause of update, delete, or select statements.
innerJoin ( string $table, string $tablePrimaryKey, string $fromTableForeignKey ) : SqlBuilder Inner join expression for SELECT SQL statement.
insert ( ) : string Build an INSERT SQL string from SqlBuilder's state.
into ( string $table ) : SqlBuilder Alias for table (insert into)
isNotNull ( string $column ) : SqlBuilder IS NOT NULL expression for WHERE clause of update, delete, or select statements
isNull ( string $column ) : SqlBuilder IS NULL expression for WHERE clause of update, delete, or select statements
leftOuterJoin ( string $table, string $tablePrimaryKey, string $fromTableForeignKey ) : SqlBuilder Left outer join expression for SELECT SQL statement.
lessThan ( string $column, numeric $value ) : SqlBuilder Less than expression for WHERE clause of update, delete, or select statements.
lessThanOrEqualTo ( string $column, numeric $value ) : SqlBuilder Less than or equal to expression for WHERE clause of update, delete, or select statements.
like ( string $column, string $value ) : SqlBuilder LIKE expression for WHERE clause of update, delete, or select statements, does not include wildcards.
limit ( integer $size ) : SqlBuilder LIMIT results to some number of records.
notEqual ( string $column, mixed $value ) : SqlBuilder Inequality than expression for WHERE clause of update, delete, or select statements.
notLike ( string $column, string $value ) : SqlBuilder NOT LIKE expression for WHERE clause of update, delete, or select statements, does not include wildcards.
offset ( integer $offset ) : SqlBuilder When used in conjunction with limit($size), offset specifies which row the results will begin at.
orderBy ( string $clause ) : SqlBuilder Add an ORDER BY expression to sql string. Example: ->orderBy('name ASC')
range ( integer $start, integer $finish ) : SqlBuilder Shortcut alias to ->limit($finish - $start)->offset($start);
select ( ) : string Build a SELECT SQL string from SqlBuilder's state.
selectAs ( string $select, string $as ) : SqlBuilder Add additional field to select statement which is aliased using the AS parameter.
table ( string $table ) : SqlBuilder Set the table of focus on a sql statement.
update ( ) : string Build an UPDATE SQL string from SqlBuilder's state.
useAssignmentsAsConditions ( boolean $bool ) : SqlBuilder Handy shortcut which allows assignments to be used as conditions in a select statement.

Защищенные методы

Метод Описание
addCondition ( string $column, mixed $value, string $operator ) : SqlBuilder Add a condition to the SqlBuilder statement. Additional logic here to prepend a table name and also keep track of which columns have already been assigned conditions to ensure we do not use two identical named parameters in PDO.
cleansedAssignmentsAsConditions ( ) : array Method for when using assignments as conditions. This purges assignments which have null values.
deleteSanityCheck ( ) Safety check used with delete.
escapeWithTicks ( $string )
groupByHelper ( )
insertSanityCheck ( ) Safety check used with insert to ensure only a table and assignments were applied.
join ( string $leftOrRight, string $innerOrOuter, string $table, string $tablePrimaryKey, string $fromTableForeignKey ) : SqlBuilder Generic join expression to be added to a SELECT SQL statement.
joinHelper ( )
orderByHelper ( )
rangeHelper ( )
selectSanityCheck ( ) Safety check used when creating a SELECT statement.
tableAsPrefix ( ) : string Helper method which returns the current table even when it is aliased due to joins between the same table.
updateSanityCheck ( ) Safety check used with update.
whereHelper ( ) * HELPER METHODS

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

addCondition() защищенный Метод

Add a condition to the SqlBuilder statement. Additional logic here to prepend a table name and also keep track of which columns have already been assigned conditions to ensure we do not use two identical named parameters in PDO.
protected addCondition ( string $column, mixed $value, string $operator ) : SqlBuilder
$column string
$value mixed
$operator string
Результат SqlBuilder

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

Assign a value to a column. Used with inserts and updates.
public assign ( string $column, mixed $value ) : SqlBuilder
$column string
$value mixed
Результат SqlBuilder

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

Shortcut alias for SqlBuilder->lessThan($column,$big)->greaterThan($column,$small)
public between ( string $column, numeric $small, numeric $big ) : SqlBuilder
$column string
$small numeric Greater than this number.
$big numeric Less than this number.
Результат SqlBuilder

cleansedAssignmentsAsConditions() защищенный Метод

Method for when using assignments as conditions. This purges assignments which have null values.
protected cleansedAssignmentsAsConditions ( ) : array
Результат array

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

Build a DELETE SQL string from SqlBuilder's state.
public delete ( ) : string
Результат string DELETE string

deleteSanityCheck() защищенный Метод

Safety check used with delete.
protected deleteSanityCheck ( )

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

Add a DISTINCT clause to SELECT SQL.
public distinct ( ) : SqlBuilder
Результат SqlBuilder

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

Equality expression for WHERE clause of update, delete, or select statements.
public equal ( string $column, mixed $value ) : SqlBuilder
$column string
$value mixed
Результат SqlBuilder

escapeWithTicks() защищенный статический Метод

protected static escapeWithTicks ( $string )

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

Alias to specify which table is being used.
public from ( string $table ) : SqlBuilder
$table string
Результат SqlBuilder

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

public getCriteria ( )

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

Return the collection of PDO named parameters and values to be applied to a parameterized PDO statement.
public getPdoArguments ( ) : array
Результат array

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

public getTable ( )

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

Greater than expression for WHERE clause of update, delete, or select statements.
public greaterThan ( string $column, numeric $value ) : SqlBuilder
$column string
$value numeric
Результат SqlBuilder

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

Greater than or equal to expression for WHERE clause of update, delete, or select statements.
public greaterThanOrEqualTo ( string $column, numeric $value ) : SqlBuilder
$column string
$value numeric
Результат SqlBuilder

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

Add an GROUP BY expression to sql string. Example: ->groupBy('name')
public groupBy ( string $clause ) : SqlBuilder
$clause string
Результат SqlBuilder

groupByHelper() защищенный Метод

protected groupByHelper ( )

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

IN to expression for WHERE clause of update, delete, or select statements.
public in ( string $column, array $value ) : SqlBuilder
$column string
$value array
Результат SqlBuilder

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

Inner join expression for SELECT SQL statement.
public innerJoin ( string $table, string $tablePrimaryKey, string $fromTableForeignKey ) : SqlBuilder
$table string
$tablePrimaryKey string
$fromTableForeignKey string
Результат SqlBuilder

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

Build an INSERT SQL string from SqlBuilder's state.
public insert ( ) : string
Результат string INSERT string.

insertSanityCheck() защищенный Метод

Safety check used with insert to ensure only a table and assignments were applied.
protected insertSanityCheck ( )

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

Alias for table (insert into)
public into ( string $table ) : SqlBuilder
$table string
Результат SqlBuilder

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

IS NOT NULL expression for WHERE clause of update, delete, or select statements
public isNotNull ( string $column ) : SqlBuilder
$column string
Результат SqlBuilder

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

IS NULL expression for WHERE clause of update, delete, or select statements
public isNull ( string $column ) : SqlBuilder
$column string
Результат SqlBuilder

join() защищенный Метод

Generic join expression to be added to a SELECT SQL statement.
protected join ( string $leftOrRight, string $innerOrOuter, string $table, string $tablePrimaryKey, string $fromTableForeignKey ) : SqlBuilder
$leftOrRight string
$innerOrOuter string
$table string
$tablePrimaryKey string
$fromTableForeignKey string
Результат SqlBuilder

joinHelper() защищенный Метод

protected joinHelper ( )

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

Left outer join expression for SELECT SQL statement.
public leftOuterJoin ( string $table, string $tablePrimaryKey, string $fromTableForeignKey ) : SqlBuilder
$table string
$tablePrimaryKey string
$fromTableForeignKey string
Результат SqlBuilder

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

Less than expression for WHERE clause of update, delete, or select statements.
public lessThan ( string $column, numeric $value ) : SqlBuilder
$column string
$value numeric
Результат SqlBuilder

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

Less than or equal to expression for WHERE clause of update, delete, or select statements.
public lessThanOrEqualTo ( string $column, numeric $value ) : SqlBuilder
$column string
$value numeric
Результат SqlBuilder

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

LIKE expression for WHERE clause of update, delete, or select statements, does not include wildcards.
public like ( string $column, string $value ) : SqlBuilder
$column string
$value string
Результат SqlBuilder

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

LIMIT results to some number of records.
public limit ( integer $size ) : SqlBuilder
$size integer
Результат SqlBuilder

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

Inequality than expression for WHERE clause of update, delete, or select statements.
public notEqual ( string $column, mixed $value ) : SqlBuilder
$column string
$value mixed
Результат SqlBuilder

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

NOT LIKE expression for WHERE clause of update, delete, or select statements, does not include wildcards.
public notLike ( string $column, string $value ) : SqlBuilder
$column string
$value string
Результат SqlBuilder

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

When used in conjunction with limit($size), offset specifies which row the results will begin at.
public offset ( integer $offset ) : SqlBuilder
$offset integer
Результат SqlBuilder

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

Add an ORDER BY expression to sql string. Example: ->orderBy('name ASC')
public orderBy ( string $clause ) : SqlBuilder
$clause string
Результат SqlBuilder

orderByHelper() защищенный Метод

protected orderByHelper ( )

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

Shortcut alias to ->limit($finish - $start)->offset($start);
public range ( integer $start, integer $finish ) : SqlBuilder
$start integer
$finish integer
Результат SqlBuilder

rangeHelper() защищенный Метод

protected rangeHelper ( )

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

Build a SELECT SQL string from SqlBuilder's state.
public select ( ) : string
Результат string

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

->selectAs("ABS(location - 5)", 'distance') translates to => SELECT ABS(location-5) AS distance
public selectAs ( string $select, string $as ) : SqlBuilder
$select string
$as string
Результат SqlBuilder

selectSanityCheck() защищенный Метод

Safety check used when creating a SELECT statement.
protected selectSanityCheck ( )

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

Set the table of focus on a sql statement.
public table ( string $table ) : SqlBuilder
$table string
Результат SqlBuilder

tableAsPrefix() защищенный Метод

Helper method which returns the current table even when it is aliased due to joins between the same table.
protected tableAsPrefix ( ) : string
Результат string The current table which can be used as a prefix.

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

Build an UPDATE SQL string from SqlBuilder's state.
public update ( ) : string
Результат string

updateSanityCheck() защищенный Метод

Safety check used with update.
protected updateSanityCheck ( )

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

Handy shortcut which allows assignments to be used as conditions in a select statement.
public useAssignmentsAsConditions ( boolean $bool ) : SqlBuilder
$bool boolean
Результат SqlBuilder

whereHelper() защищенный Метод

* HELPER METHODS
protected whereHelper ( )

Описание свойств

$assignments защищенное свойство

protected $assignments

$conditions защищенное свойство

* UPDATE & DELETE
protected $conditions

$conditionsUsed защищенное свойство

protected $conditionsUsed

$distinct защищенное свойство

protected $distinct

$groupBy защищенное свойство

protected $groupBy

$joins защищенное свойство

protected $joins

$limit защищенное свойство

protected $limit

$offset защищенное свойство

protected $offset

$orderBy защищенное свойство

protected $orderBy

$select защищенное свойство

* SELECT
protected $select

$selectAs защищенное свойство

protected $selectAs

$table защищенное свойство

* INSERT
protected $table

$useAssignmentsAsConditions защищенное свойство

protected $useAssignmentsAsConditions

$usingAliases защищенное свойство

protected $usingAliases