vBulletin 5.6.5 API

vB_dB_QueryBuilder
in package
Uses vB_Trait_NoSerialize

This class is a base intended to contain the backend specific details for converting assertor conditions to query code. The logic is contained in the base class for the time being to allow additional sql backends to override specific functions as much of it will be applicable. We'll most likely need to heavily refactor this when we add a second backend, but that will be more efficiently done when we know what the requirements of that backend really are.

Note that this class is intended to be cached and reused therefore anything that is specific to a particular query needs to be passed as parameter to methods rather than being stored in the class itself. Only items specific to the db backend should be class members.

This is internal to the assertor interface and should not be called from the Application code directly.

Table of Contents

$bitOperators  : mixed
$db  : mixed
$debug_sql  : mixed
$operators  : mixed
Mapping of operators to text.
$quote_char  : mixed
$quotechar  : mixed
The character used for quoting in an sql string- usually '.
__construct()  : mixed
Construct the query builder
__serialize()  : mixed
__sleep()  : mixed
__unserialize()  : mixed
__wakeup()  : mixed
conditionsToFilter()  : mixed
This function generates the query text against a table.
escapeField()  : string
Handle situations were the field name might be a reserved word. Also allow for qualified names.
escapeFields()  : array<string|int, mixed>
Handle situations were the field name might be a reserved word. Also allow for qualified names.
escapeTable()  : mixed
Escapes a table name -- also qualifies it with the table prefix automatically.
makeCountQuery()  : mixed
makeDeleteQuery()  : mixed
makeInsertMultipleQuery()  : mixed
makeInsertQuery()  : mixed
makeReplaceQuery()  : mixed
makeSelectQuery()  : mixed
makeUpdateQuery()  : mixed
matchValues()  : mixed
This matches a series of values against a query string
primaryKeyToFilter()  : mixed
setDebugSQL()  : mixed
valueArrayToFilter()  : mixed
valueArrayToSetLine()  : mixed
logQuery()  : mixed
quoteValue()  : mixed

Properties

$bitOperators

protected mixed $bitOperators = array( B_dB_Query::BITFIELDS_UNSET => '&~', B_dB_Query::BITFIELDS_SET => '|')

$operators

Mapping of operators to text.

protected mixed $operators = array( B_dB_Query::OPERATOR_LT => '<', B_dB_Query::OPERATOR_LTE => '<=', B_dB_Query::OPERATOR_GT => '>', B_dB_Query::OPERATOR_GTE => '>=', B_dB_Query::OPERATOR_EQ => '=', B_dB_Query::OPERATOR_NE => '<>', //handled special, value is not used. B_dB_Query::OPERATOR_BEGINS => 'LIKE', B_dB_Query::OPERATOR_ENDS => 'LIKE', B_dB_Query::OPERATOR_INCLUDES => 'LIKE', B_dB_Query::OPERATOR_ISNULL => '#', B_dB_Query::OPERATOR_ISNOTNULL => '#', B_dB_Query::OPERATOR_AND => '#', B_dB_Query::OPERATOR_NAND => '#', )

$quotechar

The character used for quoting in an sql string- usually '.

protected mixed $quotechar = "'"

Methods

__construct()

Construct the query builder

public __construct( $db, mixed $debug_sql) : mixed
Parameters
$db :

The db backend specific interface object.

$debug_sql : mixed
Return values
mixed

__serialize()

public __serialize() : mixed
Return values
mixed

__sleep()

public __sleep() : mixed
Return values
mixed

__unserialize()

public __unserialize(mixed $serialized) : mixed
Parameters
$serialized : mixed
Return values
mixed

__wakeup()

public __wakeup() : mixed
Return values
mixed

conditionsToFilter()

This function generates the query text against a table.

public conditionsToFilter(mixed $conditions[, mixed $forcetext = array() ]) : mixed
Parameters
$conditions : mixed
$forcetext : mixed = array()
Return values
mixed

escapeField()

Handle situations were the field name might be a reserved word. Also allow for qualified names.

public escapeField(string $field) : string
Parameters
$field : string

-- the field name

Return values
string

escaped version of the field name

escapeFields()

Handle situations were the field name might be a reserved word. Also allow for qualified names.

public escapeFields(array<string|int, mixed> $fields) : array<string|int, mixed>

Handles an array of fieldnames

Parameters
$fields : array<string|int, mixed>

-- the field names

Return values
array<string|int, mixed>

escaped version of the field names

escapeTable()

Escapes a table name -- also qualifies it with the table prefix automatically.

public escapeTable(string $table) : mixed
Parameters
$table : string

-- the name of the table

Return values
mixed

makeCountQuery()

public makeCountQuery(mixed $table, mixed $filter, mixed $structure) : mixed
Parameters
$table : mixed
$filter : mixed
$structure : mixed
Return values
mixed

makeDeleteQuery()

public makeDeleteQuery(mixed $table, mixed $filter[, mixed $params = array() ]) : mixed
Parameters
$table : mixed
$filter : mixed
$params : mixed = array()
Return values
mixed

makeInsertMultipleQuery()

public makeInsertMultipleQuery(mixed $table, mixed $values[, mixed $forcetext = array() ]) : mixed
Parameters
$table : mixed
$values : mixed
$forcetext : mixed = array()
Return values
mixed

makeInsertQuery()

public makeInsertQuery(mixed $table, mixed $ignore, mixed $values[, mixed $forcetext = array() ]) : mixed
Parameters
$table : mixed
$ignore : mixed
$values : mixed
$forcetext : mixed = array()
Return values
mixed

makeReplaceQuery()

public makeReplaceQuery(mixed $table, mixed $values[, mixed $forcetext = array() ]) : mixed
Parameters
$table : mixed
$values : mixed
$forcetext : mixed = array()
Return values
mixed

makeSelectQuery()

public makeSelectQuery(mixed $table, mixed $filter, mixed $sortorder, mixed $structure[, mixed $params = array() ]) : mixed
Parameters
$table : mixed
$filter : mixed
$sortorder : mixed
$structure : mixed
$params : mixed = array()
Return values
mixed

makeUpdateQuery()

public makeUpdateQuery(mixed $table, mixed $filter, mixed $setline[, mixed $params = array() ]) : mixed
Parameters
$table : mixed
$filter : mixed
$setline : mixed
$params : mixed = array()
Return values
mixed

matchValues()

This matches a series of values against a query string

public matchValues(mixed $queryid, mixed $querystring, mixed $values[, mixed $forcetext = array() ]) : mixed
Parameters
$queryid : mixed
$querystring : mixed
$values : mixed
$forcetext : mixed = array()
Return values
mixed

primaryKeyToFilter()

public primaryKeyToFilter(mixed $primarykey, mixed &$values[, mixed $forcetext = array() ]) : mixed
Parameters
$primarykey : mixed
$values : mixed
$forcetext : mixed = array()
Return values
mixed

setDebugSQL()

public setDebugSQL(mixed $debug_sql) : mixed
Parameters
$debug_sql : mixed
Return values
mixed

valueArrayToFilter()

public valueArrayToFilter(mixed $values[, mixed $forcetext = array() ]) : mixed
Parameters
$values : mixed
$forcetext : mixed = array()
Return values
mixed

valueArrayToSetLine()

public valueArrayToSetLine(mixed $values[, mixed $forcetext = array() ]) : mixed
Parameters
$values : mixed
$forcetext : mixed = array()
Return values
mixed

logQuery()

protected logQuery(mixed $sql) : mixed
Parameters
$sql : mixed
Return values
mixed

quoteValue()

protected quoteValue(mixed $key, mixed &$value[, mixed $forcetext = array() ]) : mixed
Parameters
$key : mixed
$value : mixed
$forcetext : mixed = array()
Return values
mixed

Search results