Handling Fields and Binds for Query and SqlExpr

package salt\sql

 Methods

Escape a name for SQL use with backquote

escapeName(string $name) : string
Static

Parameters

$name

string

a SQL name : database, table, field, alias, etc...

Returns

stringSQL escaped text with backquote.

Return all binds

getBinds(string $source = \salt\ClauseType::ALL) : array<mixed,mixed[]>

Parameters

$source

string

(Optional) ClauseType or specific text for restrict returned binds to specified source

Returns

array<mixed,mixed[]>list of binds : array of array('value' => ..., 'type' => ...)

Retrieve binds for pagination (LIMIT clause)

getPaginationBinds(\salt\Pagination $pagination) : array<mixed,mixed[]>
Static

Parameters

$pagination

\salt\Pagination

the Pagination object

Returns

array<mixed,mixed[]>binds for the Pagination : array of bindName => array of ('value' => ..., 'type' => ...)

Check binds are private

isPrivateBinds() : boolean

Returns

booleanTRUE if privateBinds has been called

Set all binds values as private. They will be hidden in debug queries

privateBinds(boolean $privateBinds = TRUE) : \salt\SqlBindField

Parameters

$privateBinds

boolean

(Optional, TRUE) hide binds values in debug queries

Returns

\salt\SqlBindFieldthe current object

Retrieve the SQL text

toSQL() : string

Returns

stringthe memoized SQL text

Add a bind

addBind(mixed $value, integer $type, string $source = \salt\ClauseType::ALL) : string

Parameters

$value

mixed

value of bind

$type

integer

(FieldType) type of the field

$source

string

(Optional) ClauseType or other text : clause where the bind will be used, if we know it

Returns

stringthe bind name

Build the SQL text that using the binds

buildSQL() : string

Returns

stringthe SQL text

Link another SqlBindField to this bindFields.

linkBindsOf(\salt\SqlBindField $other, string $source = \salt\ClauseType::ALL, string $otherSource = \salt\ClauseType::ALL

Parameters

$other

\salt\SqlBindField

the other SqlBindField to link

$source

string

clause usage of the SqlBindField if we known it

$otherSource

string

restrict link to this source in $other

Exceptions

\salt\SaltException if this SqlBindField is already resolved

Remove binds (local and linked) of the specified source.

removeBinds(string $source) 

Parameters

$source

string

ClauseType of specific text

Throw an exception if called after SqlBind have been resolved

checkNotResolved() 

Exceptions

\salt\SaltException if called after toSQL()

 Properties

 

bind unique number

$_salt_bindNumber : integer

Default

0
Static
 

bind pagination unique number

$_salt_bindPaginationNumber : integer

Default

0
Static
 

list of binds

$_salt_binds : array<mixed,mixed>

Default

array()
content
array of bindName => array(
					'value' => mixed // value of bind
					'type' => int FieldType // type of field
					'private' => boolean // if value is private data (like passwords)
			)
 

list of linked binds

$_salt_others : array<mixed,\salt\SqlBindField[][]>

Default

array()
content
array of (ClauseType (source) => array of ClauseType(dest) => array of SqlBindField)
 

TRUE if binds values are private (do not display in debug queries)

$_salt_privateBinds : boolean

Default

FALSE
 

list of local binds by source

$_salt_sources : array<mixed,string[]>

Default

array()
content
array of (ClauseType => array of bindName)
 

SQL text that use the binds

$_salt_text : string

Default

NULL