Methods
Create a new CountQuery
__construct(string $sqlText, array<mixed,mixed[]> $binds)
inherited_from |
\salt\BaseQuery::__construct() |
Parameters
$sqlText
string
SQL text of the count query
$binds
array<mixed,mixed[]>
binds of the query : array of bindName => array of ('value' => ..., 'type' => ...)
Construct a new query
__construct(\salt\Base $obj)
Inherited
Parameters
$obj
\salt\Base
the object used for retrieve metadata.
If parameter is empty, the query will not be executed
disableIfEmpty(mixed $list)
Inherited
This can be used if the query contains an IN where condition with an empty array : Executing the query result in an exception,
but we can use this function for return an empty result without exception :
$q->whereAnd('ids', 'IN', $values); // will produce a bad where clause : "ids IN ()" if $values is empty
$q->disabledIfEmpty($values);
$db->execQuery($q); // valid, will not execute query, so not throw exception
Parameters
$list
mixed
Escape a name for SQL use with backquote
escapeName(string $name) : string
InheritedStatic
Parameters
$name
string
a SQL name : database, table, field, alias, etc...
Returns
string
SQL escaped text with backquote.
{@inheritDoc}
getBinds(string $source = NULL
)
Parameters
$source
string
not used here
Return all binds
getBinds(string $source = \salt\ClauseType::ALL
) : array<mixed,mixed[]>
Inherited
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' => ...)
Check if we have to execute the query
isEnabled() : boolean
Inherited
Returns
boolean
TRUE if the query can be executed, FALSE otherwise
Check binds are private
isPrivateBinds() : boolean
Inherited
Returns
boolean
TRUE if privateBinds has been called
Set all binds values as private. They will be hidden in debug queries
privateBinds(boolean $privateBinds = TRUE
) : \salt\SqlBindField
Inherited
Parameters
$privateBinds
boolean
(Optional, TRUE) hide binds values in debug queries
Returns
\salt\SqlBindField
the current object
Retrieve the COUNT query
toCountQuery() : \salt\CountQuery
Inherited
Have to be overrided by child classes if needed
Exceptions
\salt\SaltException |
if called on BaseQuery instance |
Returns
\salt\CountQuery
the SQL query for count query
Retrieve the SQL text
toSQL() : string
Inherited
Returns
string
the memoized SQL text
Add a bind
addBind(mixed $value, integer $type, string $source = \salt\ClauseType::ALL
) : string
Inherited
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
string
the bind name
Build the SQL text that using the binds
buildSQL() : string
Inherited
Returns
string
the SQL text
Link another SqlBindField to this bindFields.
linkBindsOf(\salt\SqlBindField $other, string $source = \salt\ClauseType::ALL
, string $otherSource = \salt\ClauseType::ALL
)
Inherited
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)
Inherited
Parameters
$source
string
ClauseType of specific text
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 : ClauseType or specific text
$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
string
array<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
Throw an exception if called after SqlBind have been resolved
checkNotResolved()
Inherited
Exceptions
\salt\SaltException |
if called after toSQL() |
Get the type of the field
getFieldType(string $field) : integer
Inherited
Parameters
$field
string
the fieldName
Returns
integer
FiedType type of the field
Properties
the object the query is build for
$_salt_obj : \salt\Base
binds of the query : array of bindName => array of ('value' => ..., 'type' => ...)
$_salt__binds : array<mixed,mixed[]>
SQL text of the count query
$_salt__text : string
bind unique number
$_salt_bindNumber : integer
Static
list of binds
$_salt_binds : array<mixed,mixed>
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)
) |
FALSE for never execute the query
$_salt_enabled : boolean
list of linked binds
$_salt_others : array<mixed,\salt\SqlBindField[][]>
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
list of local binds by source
$_salt_sources : array<mixed,string[]>
content |
array of (ClauseType => array of bindName) |
SQL text that use the binds
$_salt_text : string