Class DBLSQLQuery

Description

DBLQuery (abstract) subclass implementing routines common for all SQL databases.

This class and all subclass should implement DBL_DEBUG_SQL global variable. When it is set value greater than zeo, the SQL queries are printed so that application developer will see what is actually sent to database. The value is decremented each call and when comes down to zero, application stops (exit). This allows you to stop executing just before the query you are debugging is sent do SQL engine.

Located in /DBLSQLQuery.php (line 23)

DBLQuery
   |
   --DBLSQLQuery
Direct descendents
Class Description
DBLPGSQLQuery Class implementing PostgreSQL interface.
DBLMYSQLQuery Class implementing MYSQL interface.
Variable Summary
mixed $groupBy
array $having
string $idFieldName
string $sequenceName
array $where
Method Summary
DBLSQLQuery DBLSQLQuery (DBLDBDef &$def, mixed $sourceDef)
void addCondition (mixed $name, mixed $oper, mixed $value, mixed $computed)
void addRecord ()
void addSQLCondition (string $cond, bool $computed)
string buildSQL ()
void deleteRecord ()
void execSQL (string $sql, [bool $calledInternally = false])
void formatDateTime (mixed &$arr, mixed $includeDate, mixed $includeTime)
void getDefaultDateTime (mixed $date, mixed $time)
int getNoRows ()
void isEmptyDateTime (mixed $dateTime)
int lastInsertID ()
void modifyRecord ()
void nextUniqueID (int 0)
void parseDateTime (mixed $dateTime, mixed &$arr)
void reset ()
void search ()
void setGroupBy (string $def)
void setNextSearchSQL (string $sql)
void setOrder (mixed $orderDef, mixed $reverse)
Variables
mixed $generateUniqueID (line 63)
mixed $groupBy (line 67)
array $having (line 32)
  • var: Internal array where the 'having' conditions are stored.
string $idFieldName (line 45)
  • var: Name of the id field. Used when IDs are generated from sequence, otherwise it is not used. Set to 'id' by default.
string $nextSearchSQL (line 40)
  • var:

    When set, the next search() call will completely ignore set conditions, fields, orders, .. and will execute THIS SQL. Set it by the setNxtSQL() method.

    WARNING: This query MUST have correctly escaped (AddSlashes) all values!

string $sequenceName (line 56)
  • var:

    Sequence name to use to generate artifical unique key for the new record. (May be) used by the lastInsertID method. Also may be used for unique id generation (see the generateUniqueID property below).

    Defaults to empty string, but specific SQL engine implementations should set this so that lastInsertID will work(!)

    NOTE: This is ignored by DBLMYSQLQuery, since MySQL does not use sequences.

array $where (line 28)
  • var: Internal array where the 'where' conditions are stored.

Inherited Variables

Inherited from DBLQuery

DBLQuery::$conditions
DBLQuery::$def
DBLQuery::$fields
DBLQuery::$offset
DBLQuery::$orderDef
DBLQuery::$orderReferse
DBLQuery::$records
DBLQuery::$srcDef
DBLQuery::$values
Methods
Constructor DBLSQLQuery (line 75)

Constructor.

DBLSQLQuery DBLSQLQuery (DBLDBDef &$def, mixed $sourceDef)
  • DBLDBDef $def: Database definition.
  • mixed $sourceDef: Source definition. Class dependent.
addCondition (line 134)
void addCondition (mixed $name, mixed $oper, mixed $value, mixed $computed)

Redefinition of:
DBLQuery::addCondition()
Add condition to 'filter records'.
addRecord (line 302)
void addRecord ()

Redefinition of:
DBLQuery::addRecord()
Adds new record.
addSQLCondition (line 127)

Add direct SQL condition.

WARNING: The value MUST be correctly escaped (AddSlashes)!

void addSQLCondition (string $cond, bool $computed)
  • string $cond: SQL condition to add.
  • bool $computed: Indicates that we filter not by a database field, but by a computed value. Used by SQL to place the condition to HAVING section
buildLimitStatement (line 152)

Internal function to build limit statement.

This is in separate function, since it is not SQL standard, so each database implements it slightly differently.

  • return: The LIMIT statement (must start with a space).
string buildLimitStatement ()

Redefined in descendants as:
buildSQL (line 163)

Internal function to build search SQL query from set values.

  • return: Search SQL.
string buildSQL ()
deleteRecord (line 352)
void deleteRecord ()

Redefinition of:
DBLQuery::deleteRecord()
Deletes record(s).
execSQL (line 193)

Executes given SQL query.

Both internal and for user use.

WARNING: The query MUST have correctly escaped (AddSlashes) all values!

void execSQL (string $sql, [bool $calledInternally = false])
  • string $sql: SQL to execute.
  • bool $calledInternally: Set when called from DBLSQLQuery. This flag is currently used to not show SQL debug message.

Redefined in descendants as:
formatDateTime (line 367)
void formatDateTime (mixed &$arr, mixed $includeDate, mixed $includeTime)

Redefinition of:
DBLQuery::formatDateTime()
Format datetime for the database backend.
getDefaultDateTime (line 409)
void getDefaultDateTime (mixed $date, mixed $time)

Redefinition of:
DBLQuery::getDefaultDateTime()
Return default date/time/datetime in the DB notation
getNoRows (line 206)

Get number of the rows returned from the last SQL query.

Used by search().

  • return: Number of rows of -1 when it is not implemented.
int getNoRows ()
isEmptyDateTime (line 404)
void isEmptyDateTime (mixed $dateTime)

Redefinition of:
DBLQuery::isEmptyDateTime()
Return whether the date/datetime is "empty"
lastInsertID (line 260)

Returns auto increment ID of the last inserted record.

NOTE: This function does not work correctly if you set the id manually! It only works well when it was auto_incremented (MYSQL) or gerated by a sequence object.

  • return: Last insert ID, -1 when not implemented.
int lastInsertID ()

Redefined in descendants as:
modifyRecord (line 327)
void modifyRecord ()

Redefinition of:
DBLQuery::modifyRecord()
Modifies existing record(s).
nextUniqueID (line 273)

Returns next ID.

Return next unique ID, usually generated from a sequence.

void nextUniqueID (int 0)
  • int 0: Next unique ID.

Redefined in descendants as:
noDeletedRecords (line 295)

Returns number of deleted records.

  • return: Number of deleted record, -1 when no implemented.
int noDeletedRecords ()

Redefined in descendants as:
noModifiedRecords (line 284)

Returns number of modified records.

  • return: Number of modified record, -1 when no implemented.
int noModifiedRecords ()

Redefined in descendants as:
parseDateTime (line 377)
void parseDateTime (mixed $dateTime, mixed &$arr)

Redefinition of:
DBLQuery::parseDateTime()
Parse date or datetime from the database backend format to variables.
reset (line 87)
void reset ()

Redefinition of:
DBLQuery::reset()
Reset query.
search (line 214)
void search ()

Redefinition of:
DBLQuery::search()
Starts retrieving data from the data source.
setGroupBy (line 246)

Set group by clausule.

void setGroupBy (string $def)
  • string $def: Group by definition (without the "GROUP BY" statement).
setNextSearchSQL (line 236)

Set next search query to be direct SQL.

WARNING: This query MUST have correctly escaped (AddSlashes) all values!

void setNextSearchSQL (string $sql)
  • string $sql: SQL to be executed next time search() is called.
setOrder (line 98)
void setOrder (mixed $orderDef, mixed $reverse)

Redefinition of:
DBLQuery::setOrder()
Set query order.

Inherited Methods

Inherited From DBLQuery

DBLQuery::DBLQuery()
DBLQuery::addCondition()
DBLQuery::addRecord()
DBLQuery::addValue()
DBLQuery::clearConditions()
DBLQuery::clearValues()
DBLQuery::deleteRecord()
DBLQuery::formatDateTime()
DBLQuery::getDefaultDateTime()
DBLQuery::isEmptyDateTime()
DBLQuery::modifyRecord()
DBLQuery::nextRecord()
DBLQuery::parseDateTime()
DBLQuery::reset()
DBLQuery::search()
DBLQuery::setFields()
DBLQuery::setLimit()
DBLQuery::setOrder()
DBLQuery::setSource()

Documentation generated on Mon, 6 Sep 2004 21:57:17 +0200 by phpDocumentor 1.2.3