Overview

Packages

  • Actions
  • Codegen
  • Controls
    • Base
  • DatabaseAdapters
  • Events
  • None
  • Sessions
  • Tests

Classes

  • QDatabaseBase
  • QDatabaseFieldType
  • QDatabaseForeignKey
  • QDatabaseIndex
  • QDatabaseRowBase
  • QInformixPdoDatabase
  • QMySqlDatabase
  • QMySqlDatabaseField
  • QMySqli5ClusterDatabase
  • QMySqli5Database
  • QMySqli5DatabaseField
  • QMySqli5DatabaseResult
  • QMySqliDatabase
  • QMySqliDatabaseField
  • QMySqliDatabaseResult
  • QMySqliDatabaseRow
  • QOracleDatabase
  • QOracleDatabaseRow
  • QPdoDatabase
  • QPostgreSqlDatabase
  • QPostgreSqlDatabaseField
  • QPostgreSqlDatabaseResult
  • QPostgreSqlDatabaseRow
  • QPostgreSqlPdoDatabase
  • QSqLite3PdoDatabase
  • QSqlServer2005Database
  • QSqlServer2005DatabaseField
  • QSqlServer2005DatabaseResult
  • QSqlServer2005DatabaseRow
  • QSqlServerDatabase
  • QSqlServerDatabaseField
  • QSqlServerDatabaseResult
  • QSqlServerDatabaseRow

Exceptions

  • QDatabaseExceptionBase
  • QMySqliDatabaseException
  • QOracleDatabaseException
  • QPostgreSqlDatabaseException
  • QSqlServer2005DatabaseException
  • QSqlServerDatabaseException
  • Overview
  • Package
  • Class

Class QDatabaseBase

Every database adapter must implement the following 5 classes (all of which are abstract): * DatabaseBase * DatabaseFieldBase * DatabaseResultBase * DatabaseRowBase * DatabaseExceptionBase This Database library also has the following classes already defined, and Database adapters are assumed to use them internally: * DatabaseIndex * DatabaseForeignKey * DatabaseFieldType (which is an abstract class that solely contains constants)

QBaseClass
Extended by QDatabaseBase

Direct known subclasses

QMySqliDatabase, QOracleDatabase, QPdoDatabase, QPostgreSqlDatabase, QSqlServer2005Database, QSqlServerDatabase

Indirect known subclasses

QInformixPdoDatabase, QMySqlDatabase, QMySqli5ClusterDatabase, QMySqli5Database, QPostgreSqlPdoDatabase, QSqLite3PdoDatabase
Abstract
Package: DatabaseAdapters
Located at includes/framework/QDatabaseBase.class.php
Methods summary
abstract public
# Connect( )

Connects to the database

Connects to the database

abstract protected mixed
# ExecuteQuery( string $strQuery )

Sends a SQL query for execution to the database In this regard, a query is a 'SELECT' statement

Sends a SQL query for execution to the database In this regard, a query is a 'SELECT' statement

Parameters

$strQuery
The Query to be executed

Returns

mixed
Result that the database returns after running the query.
abstract protected mixed
# ExecuteNonQuery( string $strNonQuery )

Sends a non-SELECT query (such as INSERT, UPDATE, DELETE, TRUNCATE) to DB server. In most cases, the results of this function are not used and you should not send 'SELECT' queries using this method because a result is not guaranteed to be returned

Sends a non-SELECT query (such as INSERT, UPDATE, DELETE, TRUNCATE) to DB server. In most cases, the results of this function are not used and you should not send 'SELECT' queries using this method because a result is not guaranteed to be returned

If there was an error, it would most probably be caught as an exception.

Parameters

$strNonQuery
The Query to be executed

Returns

mixed
Result that the database returns after running the query
abstract public mixed|string[]
# GetTables( )

Returns the list of tables in the database (as string)

Returns the list of tables in the database (as string)

Returns

mixed|string[]
List of tables
abstract public mixed
# InsertId( null|string $strTableName = null, null|string $strColumnName = null )

Returns the ID to be inserted in a table column (normally it an autoincrement column)

Returns the ID to be inserted in a table column (normally it an autoincrement column)

Parameters

$strTableName
Table name where the ID has to be inserted
$strColumnName
Column name where the ID has to be inserted

Returns

mixed
abstract public mixed
# GetFieldsForTable( string $strTableName )

Get the list of columns/fields for a given table

Get the list of columns/fields for a given table

Parameters

$strTableName
Name of table whose fields we have to get

Returns

mixed
abstract public mixed
# GetIndexesForTable( string $strTableName )

Get list of indexes for a table

Get list of indexes for a table

Parameters

$strTableName
Name of table whose column indexes we have to get

Returns

mixed
abstract public mixed
# GetForeignKeysForTable( string $strTableName )

Get list of foreign keys for a table

Get list of foreign keys for a table

Parameters

$strTableName
Name of table whose foreign keys we are trying to get

Returns

mixed
abstract protected
# ExecuteTransactionBegin( )

This function actually begins the database transaction. Must be implemented in all subclasses. The "TransactionBegin" wrapper are meant to be called by end-user code

This function actually begins the database transaction. Must be implemented in all subclasses. The "TransactionBegin" wrapper are meant to be called by end-user code

Returns


Nothing
abstract protected
# ExecuteTransactionCommit( )

This function actually commits the database transaction. Must be implemented in all subclasses. The "TransactionCommit" wrapper are meant to be called by end-user code

This function actually commits the database transaction. Must be implemented in all subclasses. The "TransactionCommit" wrapper are meant to be called by end-user code

Returns


Nothing
abstract protected
# ExecuteTransactionRollBack( )

This function actually rolls back the database transaction. Must be implemented in all subclasses. The "TransactionRollBack" wrapper are meant to be called by end-user code

This function actually rolls back the database transaction. Must be implemented in all subclasses. The "TransactionRollBack" wrapper are meant to be called by end-user code

Returns


Nothing
public mixed
# ExecuteProcedure( $strProcName, null $params = null )

Template for executing stored procedures. Optional, for those database drivers that support it.

Template for executing stored procedures. Optional, for those database drivers that support it.

Parameters

$strProcName
$params

Returns

mixed
final public
# TransactionBegin( )

This function begins the database transaction.

This function begins the database transaction.

Returns


Nothing
final public
# TransactionCommit( )

This function commits the database transaction.

This function commits the database transaction.

Returns


Nothing

Throws

QCallerException
final public
# TransactionRollBack( )

This function rolls back the database transaction.

This function rolls back the database transaction.

Returns


Nothing
final protected
# transactionCacheFlush( )

Flushes all objects from the local cache to the actual one.

Flushes all objects from the local cache to the actual one.

final protected
# transactionCacheRestore( )

Restores the actual cache to the QApplication variable.

Restores the actual cache to the QApplication variable.

abstract public
# SqlLimitVariablePrefix( $strLimitInfo )
abstract public
# SqlLimitVariableSuffix( $strLimitInfo )
abstract public
# SqlSortByVariable( $strSortByInfo )
abstract public mixed
# Close( )

Closes the database connection

Closes the database connection

Returns

mixed
public string
# EscapeIdentifier( string $strIdentifier )

Given an identifier for a SQL query, this method returns the escaped identifier

Given an identifier for a SQL query, this method returns the escaped identifier

Parameters

$strIdentifier
Identifier to be escaped

Returns

string
Escaped identifier string
public array|string
# EscapeIdentifiers( array|string $mixIdentifiers )

Given an array of identifiers, this method returns array of escaped identifiers For corner case handling, if a single identifier is supplied, a single escaped identifier is returned

Given an array of identifiers, this method returns array of escaped identifiers For corner case handling, if a single identifier is supplied, a single escaped identifier is returned

Parameters

$mixIdentifiers
Array of escaped identifiers (array) or one unescaped identifier (string)

Returns

array|string
Array of escaped identifiers (array) or one escaped identifier (string)
public array|string
# EscapeValues( array|mixed $mixValues )

Escapes values (or single value) which we can then send to the database

Escapes values (or single value) which we can then send to the database

Parameters

$mixValues
Array of values (or a single value) to be escaped

Returns

array|string
Array of (or a single) escaped value(s)
public array
# EscapeIdentifiersAndValues( array $mixColumnsAndValuesArray )

Escapes both column and values when supplied as an array

Escapes both column and values when supplied as an array

Parameters

$mixColumnsAndValuesArray
Array with column=>value format with both (column and value) sides unescaped

Returns

array
Array with column=>value format data with both column and value escaped
public
# InsertOrUpdate( string $strTable, array $mixColumnsAndValuesArray, null|string|array $strPKNames = null )

INSERTs or UPDATEs a table

INSERTs or UPDATEs a table

Parameters

$strTable
Table name
$mixColumnsAndValuesArray

column=>value array (they are given to 'EscapeIdentifiersAndValues' method)

$strPKNames
Name(s) of primary key column(s) (expressed as string or array)
final public QDatabaseResultBase
# Query( string $strQuery )

Sends the 'SELECT' query to the database and returns the result

Sends the 'SELECT' query to the database and returns the result

Parameters

$strQuery
query string

Returns

QDatabaseResultBase
final public mixed
# NonQuery( string $strNonQuery )

This is basically the same as 'Query' but is used when SQL statements other than 'SELECT'

This is basically the same as 'Query' but is used when SQL statements other than 'SELECT'

Parameters

$strNonQuery
The SQL to be sent

Returns

mixed

Throws

QCallerException
public mixed
# __get( string $strName )

PHP magic method

PHP magic method

Parameters

$strName
Property name

Returns

mixed

Throws

Exception|QCallerException

Overrides

QBaseClass::__get()
public mixed|
# __set( string $strName, string $mixValue )

PHP magic method to set class properties

PHP magic method to set class properties

Parameters

$strName
Property name
$mixValue
Property value

Returns

mixed|

Throws

Exception|QCallerException

Overrides

QBaseClass::__set()
public QDatabaseBase
# __construct( integer $intDatabaseIndex, string[] $objConfigArray )

Constructs a Database Adapter based on the database index and the configuration array of properties for this particular adapter. Sets up the base-level configuration properties for this database, namely DB Profiling and Database Index

Constructs a Database Adapter based on the database index and the configuration array of properties for this particular adapter. Sets up the base-level configuration properties for this database, namely DB Profiling and Database Index

Parameters

$intDatabaseIndex
$objConfigArray

configuration array as passed in to the constructor by QApplicationBase::InitializeDatabaseConnections();

Returns

QDatabaseBase

Throws

Exception|QCallerException|QInvalidCastException
public
# EnableProfiling( )

Allows for the enabling of DB profiling while in middle of the script

Allows for the enabling of DB profiling while in middle of the script

public string
# SqlVariable( mixed $mixData, boolean $blnIncludeEquality = false, boolean $blnReverseEquality = false )

Properly escapes $mixData to be used as a SQL query parameter. If IncludeEquality is set (usually not), then include an equality operator. So for most data, it would just be "=". But, for example, if $mixData is NULL, then most RDBMS's require the use of "IS".

Properly escapes $mixData to be used as a SQL query parameter. If IncludeEquality is set (usually not), then include an equality operator. So for most data, it would just be "=". But, for example, if $mixData is NULL, then most RDBMS's require the use of "IS".

Parameters

$mixData
$blnIncludeEquality
whether or not to include an equality operator
$blnReverseEquality
whether the included equality operator should be a "NOT EQUAL", e.g. "!="

Returns

string
the properly formatted SQL variable
public
# PrepareStatement( $strQuery, $mixParameterArray )
public null|string
# OutputProfiling( boolean $blnPrintOutput = true )

Displays the OutputProfiling results, plus a link which will popup the details of the profiling.

Displays the OutputProfiling results, plus a link which will popup the details of the profiling.

Parameters

$blnPrintOutput

Returns

null|string
public null
# ExplainStatement( $strSql )

Executes the explain statement for a given query and returns the output without any transformation. If the database adapter does not support EXPLAIN statements, returns null.

Executes the explain statement for a given query and returns the output without any transformation. If the database adapter does not support EXPLAIN statements, returns null.

Parameters

$strSql

Returns

null
public static array
# ExtractCommentOptions( string $strComment )

Utility function to extract the json embedded options structure from the comments.

Utility function to extract the json embedded options structure from the comments.

Usage:

list($strComment, $options) = QDatabaseFieldBase::ExtractCommentOptions($strComment);

Parameters

$strComment
The comment to analyze

Returns

array
A two item array, with first item the comment with the options removed, and 2nd item the options array.
Methods inherited from QBaseClass
OverrideAttributes(), __call()
Constants summary
string Adapter

Adapter name

Adapter name

# 'Generic Database Adapter (Abstract)'
Properties summary
protected integer $intDatabaseIndex

Database Index according to the configuration file

Database Index according to the configuration file

#
protected boolean $blnEnableProfiling

Has the profiling been enabled?

Has the profiling been enabled?

#
protected $strProfileArray
#
protected $objConfigArray
#
protected boolean $blnConnectedFlag
# false
protected string $strEscapeIdentifierBegin

The beginning part of characters which can escape identifiers in a SQL query for the database

The beginning part of characters which can escape identifiers in a SQL query for the database

# '"'
protected string $strEscapeIdentifierEnd

The ending part of characters which can escape identifiers in a SQL query for the database

The ending part of characters which can escape identifiers in a SQL query for the database

# '"'
protected boolean $blnOnlyFullGroupBy
# false
protected integer $intTransactionDepth

The transaction depth value. It is incremented on a transaction begin, decremented on a transaction commit, and reset to zero on a roll back. It is used to implement the recursive transaction functionality.

The transaction depth value. It is incremented on a transaction begin, decremented on a transaction commit, and reset to zero on a roll back. It is used to implement the recursive transaction functionality.

# 0
protected static QStack $objCacheProviderStack

The stack of cache providers. It is populated with cache providers from different databases, if there are transaction of one DB in the middle of the transaction of another DB.

The stack of cache providers. It is populated with cache providers from different databases, if there are transaction of one DB in the middle of the transaction of another DB.

#
Magic properties summary
public boolean $Caching

if true objects loaded from this database will be kept in cache (assuming a cache provider is also configured)

public read-only string $EscapeIdentifierBegin
public read-only string $EscapeIdentifierEnd
public read-only boolean $EnableProfiling
public read-only integer $AffectedRows
public read-only string $Profile
public read-only integer $DatabaseIndex
public read-only integer $Adapter
public read-only string $Server
public read-only string $Port
public read-only string $Database
public read-only string $Service
public read-only string $Protocol
public read-only string $Host
public read-only string $Username
public read-only string $Password
public read-only string $DateFormat
public read-only boolean $OnlyFullGroupBy

database adapter sub-classes can override and set this property to true to prevent the behavior of automatically adding all the columns to the select clause when the query has an aggregation clause.

API documentation generated by ApiGen