Query for INSERT

package salt\sql\queries
inherited_from \salt\BaseQuery

 Methods

Construct a new INSERT query

__construct(array<mixed,\salt\Base>|\salt\Base $objects) 
inherited_from \salt\BaseQuery::__construct()

Parameters

$objects

array<mixed,\salt\Base>\salt\Base

object or array of object (of same type) to insert

Construct a new query

__construct(\salt\Base $obj) 
Inherited

Parameters

$obj

\salt\Base

the object is used for retrieve metadata.

Return all binds

getBinds() : array<mixed,mixed[]>
Inherited

Returns

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

Retrieve the number of objects passed in query constructor

getInsertObjectCount() : integer

Returns

integerthe number of expected objects to insert

Retrieve the SQL text for COUNT query

toCountSQL() : string
Inherited

Have to be overrided by child classes if needed

Exceptions

\salt\SaltException if called

Returns

stringthe SQL text for count query

Retrieve the SQL text of the query

toSQL(\salt\Pagination $pagination = NULL
see
inherited_from \salt\BaseQuery::toSQL()

Parameters

$pagination

\salt\Pagination

not used here

Retrieve the SQL text of the query

toSQL(\salt\Pagination $pagination = NULL) : string
Inherited

Parameters

$pagination

\salt\Pagination

the object for handle paging

Returns

stringthe SQL text of the query with bind placeholders

Add a bind

addBind(mixed $value, integer $type) : string
Inherited

Parameters

$value

mixed

value of bind

$type

integer

(FieldType) type of the field

Returns

stringthe bind name

Link one or more binds to a source

addBindsSource(string $source, string|array<mixed,string> $binds) 
Inherited

Parameters

$source

string

caller of bind (SELECT, WHERE, GROUPBY, etc...)

$binds

stringarray<mixed,string>

bind name or list of binds name

Retrieve binds linked to one or more sources

getBindsBySource(string $sources) : array<mixed,string>
Inherited

Parameters

$sources

string

... $sources function take unlimited source bind parameters

Returns

array<mixed,string>binds registered with theses sources

Used for replace something that can be a value by a bind or a SQL text

resolveFieldName(string $source, mixed|\salt\SqlExpr $fieldNameOrValue, mixed|\salt\SqlExpr $fieldOfValue = NULL) : string | array<mixed,string>
Inherited

Parameters

$source

string

caller of resolve : SELECT, WHERE, etc...

$fieldNameOrValue

mixed\salt\SqlExpr

a FieldName (string) or SqlExpr or potential value (int, string, array) if 3rd argument is provided

$fieldOfValue

mixed\salt\SqlExpr

a Field related to the value. Can be a SqlExpr or a string. Can be NULL if 2nd argument is a string fieldName

Returns

stringarray<mixed,string>absolute field name (alias.fieldname) or string with bind values or array of bind values if 2nd argument is an array of values

Set or replace a bind linked to a specific source

setOrRemplaceBind(string $source, mixed $value, integer $type) : string
Inherited

Only work with 1 bind by source name

Parameters

$source

string

source of bind

$value

mixed

a value for bind

$type

integer

FieldType

Returns

stringthe bind added or replaced

Get the type of the field

getFieldType(string $field) : integer
Inherited

Parameters

$field

string

the fieldName

Returns

integerFiedType type of the field

 Properties

 

bind unique number

$bindNumber : integer

Default

0
Static
 

list of binds

$binds : array<mixed,mixed>

Default

array()
content
array of bindName => array(
					'value' => mixed // value of bind
					'type' => int FieldType // type of field
			)
 

by source (SELECT, WHERE, GROUPBY, LIMIT, etc...)

$bindsSource : \salt\binds

Default

array()
content array of source => array(binds)
 

internal instance of object the query is build for

$obj : \salt\Base

Default

 

array of modified field names

$fields : array<mixed,string>

Default

array()
 

list of objects to insert

$objects : array<mixed,\salt\Base>

Default

 

list of values to insert

$sets : array<mixed,string[]>

Default

array()
content array of array of field=>bind