class SqlBuilder

Builds SQL query.

SqlBuilder is based on great library NotORM http://www.notorm.com written by Jakub Vrana.

Properties

protected string $tableName
protected IConventions $conventions
protected string $delimitedTable
protected array $select
protected array $where
protected array $joinCondition
protected array $conditions
protected array $parameters
protected array $order
protected int $limit
protected int $offset
protected string $group
protected string $having
protected array $reservedTableNames
protected array $aliases
protected string $currentAlias

Methods

__construct($tableName, Context $context)

No description

string
getTableName()

No description

buildInsertQuery()

No description

buildUpdateQuery()

No description

buildDeleteQuery()

No description

string
getSelectQueryHash(array $columns = null)

Returns select query hash for caching.

string
buildSelectQuery(array $columns = null)

Returns SQL query.

array
getParameters()

No description

importConditions(SqlBuilder $builder)

No description

bool
importGroupConditions(SqlBuilder $builder)

No description

addSelect($columns, ...$params)

No description

array
getSelect()

No description

resetSelect()

No description

bool
addWhere($condition, ...$params)

No description

array
addJoinCondition($tableChain, $condition, ...$params)

No description

bool
addCondition($condition, array $params, array $conditions, array $conditionsParameters)

No description

array
getConditions()

No description

void
addAlias($chain, $alias)

Adds alias.

void
checkUniqueTableName($tableName, $chain)

No description

addOrder($columns, ...$params)

No description

setOrder(array $columns, array $parameters)

No description

array
getOrder()

No description

void
setLimit($limit, $offset)

No description

int|null
getLimit()

No description

int|null
getOffset()

No description

setGroup($columns, ...$params)

No description

string
getGroup()

No description

setHaving($having, ...$params)

No description

string
getHaving()

No description

string
buildSelect(array $columns)

No description

array
parseJoinConditions($joins, $joinConditions)

No description

getSortedJoins($table, $leftJoinDependency, $tableJoins, $finalJoins)

No description

parseJoins($joins, $query)

No description

string
parseJoinsCb($joins, $match)

No description

string
buildQueryJoins(array $joins, array $leftJoinConditions = [])

No description

array
buildJoinConditions()

No description

string
buildConditions()

No description

string
buildQueryEnd()

No description

string
tryDelimite($s)

No description

bool
addConditionComposition(array $columns, array $parameters, array $conditions, array $conditionsParameters)

No description

Details

at line 94
__construct($tableName, Context $context)

No description

Parameters

$tableName
Context $context

at line 109
string getTableName()

No description

Return Value

string

at line 118
buildInsertQuery()

No description

at line 127
buildUpdateQuery()

No description

at line 146
buildDeleteQuery()

No description

at line 161
string getSelectQueryHash(array $columns = null)

Returns select query hash for caching.

Parameters

array $columns

Return Value

string

at line 195
string buildSelectQuery(array $columns = null)

Returns SQL query.

Parameters

array $columns

Return Value

string

at line 246
array getParameters()

No description

Return Value

array

at line 262
importConditions(SqlBuilder $builder)

No description

Parameters

SqlBuilder $builder

at line 274
bool importGroupConditions(SqlBuilder $builder)

No description

Parameters

SqlBuilder $builder

Return Value

bool

at line 290
addSelect($columns, ...$params)

No description

Parameters

$columns
...$params

at line 303
array getSelect()

No description

Return Value

array

at line 309
resetSelect()

No description

at line 319
bool addWhere($condition, ...$params)

No description

Parameters

$condition
...$params

Return Value

bool

at line 328
array addJoinCondition($tableChain, $condition, ...$params)

No description

Parameters

$tableChain
$condition
...$params

Return Value

array

at line 341
protected bool addCondition($condition, array $params, array $conditions, array $conditionsParameters)

No description

Parameters

$condition
array $params
array $conditions
array $conditionsParameters

Return Value

bool

at line 460
array getConditions()

No description

Return Value

array

at line 472
void addAlias($chain, $alias)

Adds alias.

Parameters

$chain
$alias

Return Value

void

at line 487
protected void checkUniqueTableName($tableName, $chain)

No description

Parameters

$tableName
$chain

Return Value

void

at line 502
addOrder($columns, ...$params)

No description

Parameters

$columns
...$params

at line 509
setOrder(array $columns, array $parameters)

No description

Parameters

array $columns
array $parameters

at line 519
array getOrder()

No description

Return Value

array

at line 530
void setLimit($limit, $offset)

No description

Parameters

$limit
$offset

Return Value

void

at line 540
int|null getLimit()

No description

Return Value

int|null

at line 549
int|null getOffset()

No description

Return Value

int|null

at line 555
setGroup($columns, ...$params)

No description

Parameters

$columns
...$params

at line 565
string getGroup()

No description

Return Value

string

at line 571
setHaving($having, ...$params)

No description

Parameters

$having
...$params

at line 581
string getHaving()

No description

Return Value

string

at line 593
protected string buildSelect(array $columns)

No description

Parameters

array $columns

Return Value

string

at line 602
protected array parseJoinConditions($joins, $joinConditions)

No description

Parameters

$joins
$joinConditions

Return Value

array

at line 635
protected getSortedJoins($table, $leftJoinDependency, $tableJoins, $finalJoins)

No description

Parameters

$table
$leftJoinDependency
$tableJoins
$finalJoins

at line 669
protected parseJoins($joins, $query)

No description

Parameters

$joins
$query

at line 691
string parseJoinsCb($joins, $match)

No description

Parameters

$joins
$match

Return Value

string

at line 797
protected string buildQueryJoins(array $joins, array $leftJoinConditions = [])

No description

Parameters

array $joins
array $leftJoinConditions

Return Value

string

at line 813
protected array buildJoinConditions()

No description

Return Value

array

at line 826
protected string buildConditions()

No description

Return Value

string

at line 835
protected string buildQueryEnd()

No description

Return Value

string

at line 854
protected string tryDelimite($s)

No description

Parameters

$s

Return Value

string

at line 865
protected bool addConditionComposition(array $columns, array $parameters, array $conditions, array $conditionsParameters)

No description

Parameters

array $columns
array $parameters
array $conditions
array $conditionsParameters

Return Value

bool

Traits

SmartObject