abstract class vB_dB_Query

The base query class for the assertor query object.

For the moment most of the query logic is here rather than the type specific child classes. The main reason for this is that this is generally applicable to SQL backends. We'll need to refactor this eventually, but that's probably better done when we have a better sense of the requirements of the additional backends.

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

Traits

Constants

CONDITIONS_KEY

This class is called by the new vB_dB_Assertor database class It does the actual execution. See the vB_dB_Assertor class for more information

$queryid can be either the id of a query from the dbqueries table, or the name of a table.

if it is the name of a table , $params MUST include self::TYPE_KEY of either update, insert, select, or delete.

$params includes a list of parameters. Here's how it gets interpreted.

If the queryid was the name of a table and type was "update", one of the params must be the primary key of the table. All the other parameters will be matched against the table field names, and appropriate fields will be updated. The return value will be false if an error is generated and true otherwise

If the queryid was the name of a table and type was "delete", one of the params must be the primary key of the table. All the other parameters will be ignored The return value will be false if an error is generated and true otherwise

If the queryid was the name of a table and type was "insert", all the parameters will be matched against the table field names, and appropriate fields will be set in the insert. The return value is the primary key of the inserted record.

If the queryid was the name of a table and type was "select", all the parameters will be matched against the table field names, and appropriate fields will be part of the "where" clause of the select. The return value will be a vB_dB_Result object The return value is the primary key of the inserted record.

If the queryid is the key of a record in the dbqueries table then each params value will be matched to the query. If there are missing parameters we will return false. If the query generates an error we return false, and otherwise we return either true, or an inserted id, or a recordset.

FIELDS_KEY

VALUES_KEY

TYPE_KEY

COLUMNS_KEY

QUERYTYPE_KEY

OPERATOR_KEY

PRIORITY_QUERY

DEBUG_QUERY

CONDITION_ALL

OPERATOR_LT

OPERATOR_LTE

OPERATOR_GT

OPERATOR_GTE

OPERATOR_EQ

OPERATOR_NE

OPERATOR_BEGINS

OPERATOR_ENDS

OPERATOR_INCLUDES

OPERATOR_ISNULL

OPERATOR_ISNOTNULL

OPERATOR_AND

OPERATOR_NAND

OPERATOR_OR

OPERATOR_FALSE

VALUE_ISNULL

QUERY_SELECT

QUERY_COUNT

QUERY_STORED

QUERY_UPDATE

QUERY_INSERT

QUERY_INSERTIGNORE

QUERY_REPLACE

QUERY_MULTIPLEINSERT

QUERY_DELETE

QUERY_METHOD

QUERY_DROP

QUERY_CREATE

QUERY_ALTER

PARAM_LIMIT

PARAM_LIMITSTART

PARAM_LIMITPAGE

BITFIELDS_KEY

SORT_ASC

SORT_DESC

QUERY_TABLE

Properties

protected $db The database connection *
protected $dbSlave And the slave connection *
protected $userinfo The user info **
protected $quotechar The character used for quoting in an sql string- usually '.
protected $table_query We need to know whether we are using a table query when we compose the sql replacements *
protected $query_type
protected $data_loaded are we ready to execute? *
protected $datafields are we ready to execute? *
protected $primarykey What is the primary key of the table, if applicable?
protected $query_string What is the text of the stored query from the dictionary, if applicable?
protected $params The parameters are are going to use to populate the query data
protected $structure The array from a describe statement for database structure, if applicable?
protected $replacements The replacement variables from a stored query*
protected $queryid The original query id *
protected $error The most recent error *
protected $errors All errors for this query *
protected $sortorder sortorder, for select queries only (obviously) *
protected $table_data This is the definition for tables we will process through. It saves a database query to put them here.
protected $query_data
protected $method_name
protected $querydef_object
protected $class_name
protected $forcetext
protected $querydefs
protected bool $debugDisplayNextQuerySql Causes the SQL for the next query that is exectuted to be displayed for debugging purposes. This only works if debug mode is turned on
static protected $configDebug
static protected $queryBuilders Holds the query builder object. We don't need a copy for every query so we store them here.

Methods

__sleep()

No description

__wakeup()

No description

static 
getQuery($queryid, $params, $db, $userinfo, $dbtype, $dbSlave)

No description

__construct($queryid, $db, $userinfo, $dbSlave)

validates that we know what to do with this queryid

setQuery($params, $sortorder)

This loads and validates the data- ensures we have all we need

setTableQuery($params, $sortorder)

This loads and validates the data for a table. There's some extra work required

mixed
execSQL()

This function is the public interface to actually execute the SQL.

mixed
buildQuery($values)

This function generates the query text against a table.

debugDisplayNextQuerySql() deprecated

Causes the SQL for the next query that is exectuted to be displayed for debugging purposes. This only works if debug mode is turned on

setQueryData(mixed $queryData)

Sets the query Query definitions

setTableData(mixed $tableData, string $queryid)

Sets the query Table definitions

setQueryDefs(object $querydefs)

Sets the querydef object

setStructure(object $structure)

Sets the table structure.

Details

in vB_Trait_NoSerialize at line 15
__sleep()

in vB_Trait_NoSerialize at line 20
__wakeup()

at line 219
static getQuery($queryid, $params, $db, $userinfo, $dbtype, $dbSlave)

Parameters

$queryid
$params
$db
$userinfo
$dbtype
$dbSlave

at line 367
protected __construct($queryid, $db, $userinfo, $dbSlave)

validates that we know what to do with this queryid

Parameters

$queryid
$db
$userinfo
$dbSlave

at line 379
abstract setQuery($params, $sortorder)

This loads and validates the data- ensures we have all we need

Parameters

$params
$sortorder

at line 386
setTableQuery($params, $sortorder)

This loads and validates the data for a table. There's some extra work required

Parameters

$params
$sortorder

at line 451
abstract mixed execSQL()

This function is the public interface to actually execute the SQL.

Return Value

mixed

at line 460
protected mixed buildQuery($values)

This function generates the query text against a table.

Parameters

$values

Return Value

mixed

at line 580
debugDisplayNextQuerySql() deprecated

deprecated never worked quite right and now does nothing.

Causes the SQL for the next query that is exectuted to be displayed for debugging purposes. This only works if debug mode is turned on

at line 590
protected setQueryData(mixed $queryData)

Sets the query Query definitions

Parameters

mixed $queryData The query data from the querydefs

at line 601
protected setTableData(mixed $tableData, string $queryid)

Sets the query Table definitions

Parameters

mixed $tableData The table data from the querydefs
string $queryid

at line 616
protected setQueryDefs(object $querydefs)

Sets the querydef object

Parameters

object $querydefs The querydef object

at line 627
protected setStructure(object $structure)

Sets the table structure.

Parameters

object $structure The querydef object