Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
DAL Class Reference
Inheritance diagram for DAL:
MatrixDAL

Static Public Member Functions

static getQuery ($systemid, $queryid, $bindValues=TRUE)
 
static getAssoc (Query $dalQuery, $col=NULL)
 
static getAll (Query $dalQuery)
 
static getOne (Query $dalQuery)
 
static getDALQuery ($systemid, $queryid, $method)
 
static getGrouped (Query $dalQuery)
 
static getGroupedAssoc (Query $dalQuery)
 
static executeGrouped ($systemid, $queryid)
 
static executeGroupedAssoc ($systemid, $queryid)
 
static executeAssoc ($systemid, $queryid, $col=NULL)
 
static executeAll ($systemid, $queryid)
 
static executeOne ($systemid, $queryid)
 
static executeQuery ($systemid, $queryid=NULL)
 
static getExecuteQuery ($systemid, $queryid=NULL)
 
static getExecuteAll ($systemid, $queryid)
 
static executeDALQuery (Query $query, $execMethod=NULL)
 
static execPdoQuery ($query)
 
static executePdoAssoc ($query, $col=NULL)
 
static executePdoAll ($query)
 
static executePdoGrouped ($query)
 
static executePdoGroupedAssoc ($query)
 
static executePdoOne ($query)
 
static executeSql ($sql)
 
static executeSqlAssoc ($sql, $col=NULL)
 
static executeSqlAll ($sql)
 
static executeSqlGrouped ($sql)
 
static executeSqlGroupedAssoc ($sql)
 
static executeSqlOne ($sql)
 
static executeQueries ($sql)
 
static query ($sql)
 
static beginTransaction ()
 
static commit ()
 
static rollBack ()
 
static lastInsertId ($sequenceName)
 
static dbConnect (array &$dsn=NULL, $conn_id='db', $oci_force_new=FALSE)
 
static changeDb ($conn_id)
 
static restoreDb ()
 
static getCurrentDbId ()
 
static transactionSupport ($conn_id=NULL)
 
static dbClose ($conn_id)
 
static dbConnected ($conn_id=NULL)
 
static getDsn ($conn_id=NULL)
 
static getDsnFromConfig ($conn_id)
 
static getDbName ($conn_id)
 
static getDb ($conn_id=NULL)
 
static getDbType ($readable=FALSE, $conn_id=NULL)
 
static requireQueryClass ($systemid)
 
static getOvenPath ($system=NULL)
 
static getQueryStorePath ()
 
static getQueryObject ($id)
 
static getSqlQueriesFromFile ($path)
 
static isDALQuery ($query)
 
static getLoggedQueries ()
 
static clearLoggedQueries ()
 
static setOciCommitOnSuccess ($switch)
 

Static Protected Member Functions

static _startQueryTimer ($query)
 
static _endQueryTimer ()
 

Detailed Description

DAL.

DAL (Database Abstraction Layer) class handles parsing of XML SQL queries. It converts XML based SQL queries to generic PHP arrays so that they can be converted to actual SQL queries by the DALConverter class.

DAL class can also validates schemas and quries.

DAL class also handles database connection and access.

NB: the Matrix (MySource 3.x) version of the DAL is resorting to using OCI8 functionality, instead of PDO, when connecting to Oracle (v.9+) databases. This is due to the instability and lack of support of PDO_OCI towards CLOB fields at the moment (as of January 2008). When PDO_OCI better supports the CLOB field type, Oracle support will again use PDO_OCI. Returns from OCI8 will be changed to expected PDO format for consistency.

Since
4.0.0

Definition at line 41 of file DAL.inc.

Member Function Documentation

static _endQueryTimer ( )
staticprotected

Stops query timer.

Since
4.0.0
Returns
void

Definition at line 1813 of file DAL.inc.

static _startQueryTimer (   $query)
staticprotected

Starts query timer for given queryid.

Parameters
string$queryidId of the query.
Since
4.0.0
Returns
void

Definition at line 1790 of file DAL.inc.

static beginTransaction ( )
static

Initiates a transaction in the current database.

Since
4.0.0
Returns
void

Definition at line 1090 of file DAL.inc.

static changeDb (   $conn_id)
static

Change database connection.

Parameters
string$conn_idConnection ID to change
Since
4.0.0
Returns
void
Exceptions
DALExceptionIf the connection identified by the ID is not (yet) connected.

Definition at line 1359 of file DAL.inc.

static clearLoggedQueries ( )
static

Clears logged queries.

Returns
void

Definition at line 1843 of file DAL.inc.

static commit ( )
static

Commits a transaction in the current database.

Since
4.0.0
Returns
void

Definition at line 1116 of file DAL.inc.

static dbClose (   $conn_id)
static

Close the specified database connection.

Parameters
string$conn_idConnection ID to close.
Since
4.0.0
Returns
void
Exceptions
DALExceptionIf connection doesn't exist, or connection is still in the stack.

Definition at line 1451 of file DAL.inc.

static dbConnect ( array &  $dsn = NULL,
  $conn_id = 'db',
  $oci_force_new = FALSE 
)
static

Connects to the selected database.

Throws DALException if cannot connect to db else returns PDO object.

Parameters
array$dsnDSN array. This argument has been changed to "pass by reference" type to keep backward compatibility since the support of multiple DSNs (feature #5541) because there are a few places where this DSN array is used as a single DSN after invoking this method, e.g. MySource's changeDatabaseConnection() method.
string$conn_idUnique connection ID
boolean$oci_force_newforce a new connection for oci
Since
4.0.0
Returns
object
Exceptions
DALExceptionIf db connection fails.

Definition at line 1209 of file DAL.inc.

static dbConnected (   $conn_id = NULL)
static

Returns true if there is an active database connection.

If the optional $conn_id parameter is provided, this function will return the existence or otherwise of that connection. If omitted, it will return the existence of ANY open connection.

Parameters
string$conn_idConnection ID to check.
Since
4.0.0
Returns
boolean

Definition at line 1488 of file DAL.inc.

static execPdoQuery (   $query)
static

Executes the given PDO statement and returns the number of returned or affected rows.

Parameters
PDOStatement$queryPDOStatement object.
Since
4.0.0
Returns
int

We can get the queryString from a pdo statement but not an oracle statement unfortunately.

Definition at line 580 of file DAL.inc.

static executeAll (   $systemid,
  $queryid 
)
static

Returns all rows in an array.

This function will call getQuery() and getAll().

Parameters
string$systemidSystem's ID.
string$queryidID of the SQL query.
Since
4.0.0
Returns
array

Definition at line 430 of file DAL.inc.

static executeAssoc (   $systemid,
  $queryid,
  $col = NULL 
)
static

Returns all rows as an associative array.

This function will call getQuery() and getAssoc().

Parameters
string$systemidSystem's ID.
string$queryidID of the SQL query.
integer$colColumn to retrieve.
Since
4.0.0
Returns
array

Definition at line 409 of file DAL.inc.

static executeDALQuery ( Query  $query,
  $execMethod = NULL 
)
static

Executes a DALQuery.

Parameters
Query$queryThe Query to execute.
string$execMethodOptional execute method i.e. Assoc, Grouped.
Since
4.0.0
Returns
array

Definition at line 554 of file DAL.inc.

static executeGrouped (   $systemid,
  $queryid 
)
static

Returns all rows grouped by first column.

Parameters
string$systemidSystem's ID.
string$queryidID of the SQL query.
Since
4.0.0
Returns
array

Definition at line 367 of file DAL.inc.

static executeGroupedAssoc (   $systemid,
  $queryid 
)
static

Returns all rows grouped by first column, with subsequent fields keyed by their field name..

Parameters
string$systemidSystem's ID.
string$queryidID of the SQL query.
Since
4.0.0
Returns
array

Definition at line 387 of file DAL.inc.

static executeOne (   $systemid,
  $queryid 
)
static

Returns a single value.

This function will call getQuery() and getOne().

Parameters
string$systemidSystem's ID.
string$queryidID of the SQL query.
Since
4.0.0
Returns
array

Definition at line 451 of file DAL.inc.

static executePdoAll (   $query)
static

Executes the given PDO statement and returns all rows in an array.

Parameters
PDOStatement$queryPDOStatement object to execute.
Since
4.0.0
Returns
array

Definition at line 685 of file DAL.inc.

static executePdoAssoc (   $query,
  $col = NULL 
)
static

Executes the given PDO statement and returns all rows in an associative array.

If optional parameter $col is specified, this does NOT return an associative array, but rather values from a single column.

Parameters
PDOStatement$queryPDOStatement object to execute.
integer$colColumn to retrieve (zero-indexed).
Since
4.0.0
Returns
array

Definition at line 636 of file DAL.inc.

static executePdoGrouped (   $query)
static

Executes the given PDO statement and returns all rows grouped by the first column.

Parameters
PDOStatement$queryPDOStatement object to execute.
Since
4.0.0
Returns
array

Definition at line 722 of file DAL.inc.

static executePdoGroupedAssoc (   $query)
static

Executes the given PDO statement and returns all rows grouped by the first column, with subsequent fields keyed by their field name.

Parameters
PDOStatement$queryPDOStatement object to execute.
Since
4.0.0
Returns
array

Definition at line 776 of file DAL.inc.

static executePdoOne (   $query)
static

Executes the given PDO statement and returns a single value

Parameters
PDOStatement$queryPDOStatement object to execute.
Since
4.0.0
Returns
array

Definition at line 834 of file DAL.inc.

static executeQueries (   $sql)
static

Executes multiple queries in one SQL string.

Each sql statement must be separated by a semi-colon. Create table statements should use this function since they may have multiple queries to create indexes, constraints, etc. Also, it should not be used for output statements (i.e. SELECT).

Parameters
string$sqlSQL statements.
Since
4.0.0
Returns
void

Definition at line 1050 of file DAL.inc.

static executeQuery (   $systemid,
  $queryid = NULL 
)
static

Executes a query and returns the number of rows affected.

Note: $systemid can be a PDOStatement object. If $systemid is PDOStatement then $queryid (2nd argument) can be NULL.

Parameters
string | object$systemidSystem's ID.
string$queryidID of the SQL query.
Since
4.0.0
Returns
integer
Exceptions
DALExceptionIf no query provided or query execution failed.

Definition at line 480 of file DAL.inc.

static executeSql (   $sql)
static

Executes the given SQL query.

Returns the number of rows affected by the statement.

Parameters
string$sqlSql query to execute.
Since
4.0.0
Returns
integer

Definition at line 872 of file DAL.inc.

static executeSqlAll (   $sql)
static

Executes the given SQL query and returns all rows in an array.

Parameters
string$sqlSql query to execute.
Since
4.0.0
Returns
array

Definition at line 943 of file DAL.inc.

static executeSqlAssoc (   $sql,
  $col = NULL 
)
static

Executes the given SQL query and returns all rows in an associative array.

If optional parameter $col is specified, this does NOT return an associative array, but rather values from a single column.

Parameters
string$sqlSql query to execute.
integer$colColumn to retrieve (zero-indexed).
Since
4.0.0
Returns
array

Definition at line 920 of file DAL.inc.

static executeSqlGrouped (   $sql)
static

Executes the given SQL query and returns all rows grouped by the first column.

Parameters
string$sqlSql query to execute.
Since
4.0.0
Returns
array

Definition at line 969 of file DAL.inc.

static executeSqlGroupedAssoc (   $sql)
static

Executes the given SQL query and returns all rows grouped by the first column, with subsequent fields keyed by their field name.

Parameters
string$sqlSql query to execute.
Since
4.0.0
Returns
array

Definition at line 995 of file DAL.inc.

static executeSqlOne (   $sql)
static

Executes the given SQL query and returns a single value

Parameters
string$sqlSql query to execute.
Since
4.0.0
Returns
array

Definition at line 1020 of file DAL.inc.

static getAll ( Query  $dalQuery)
static

Returns all rows in an array.

Parameters
Query$dalQuerySQL Query to execute.
Since
4.0.0
Returns
array

Definition at line 252 of file DAL.inc.

static getAssoc ( Query  $dalQuery,
  $col = NULL 
)
static

Returns all rows as an associative array.

Parameters
Query$dalQuerySQL Query to execute.
integer$colColumn to retrieve.
Since
4.0.0
Returns
array

Definition at line 229 of file DAL.inc.

static getCurrentDbId ( )
static

Get the current database connection ID.

Since
4.0.0
Returns
void
Exceptions
DALExceptionIf the database connection stack is empty.

Definition at line 1402 of file DAL.inc.

static getDALQuery (   $systemid,
  $queryid,
  $method 
)
static

Returns an array of data about the SQL query.

This is used if the query is not to be executed yet, and rather a representation of the query's SQL, along with its' bindings and their values.

Parameters
string$systemidSystem name that the query belongs to.
string$queryidID of the query.
string$methodMethod used to retrieve the query(getAssoc etc).
Since
4.0.0
Returns
array

Definition at line 304 of file DAL.inc.

static getDb (   $conn_id = NULL)
static

Returns the PDO object for the current database.

Parameters
string$conn_idIf provided, the function returns a specific connection. If omitted, the function returns the current connection.
Since
4.0.0
Returns
PDO

Definition at line 1587 of file DAL.inc.

static getDbName (   $conn_id)
static

Returns the current database name using its DSN.

Since
4.0.0
Returns
string

Definition at line 1558 of file DAL.inc.

static getDbType (   $readable = FALSE,
  $conn_id = NULL 
)
static

Returns the current database connection's type.

Parameters
boolean$readableIf true readable name will be returned. For example, mysql => Mysql, pgsql => Postgres.
string$conn_idIf provided, the function checks this specified connection. If omitted, the function returns the current connection.
Since
4.0.0
Returns
string
Exceptions
DALExceptionIf db type is not found or it is invalid.

Definition at line 1625 of file DAL.inc.

static getDsn (   $conn_id = NULL)
static

Returns the DSN array for the current database configuration.

Parameters
string$conn_idConnection ID to get details from. If omitted, use current connection.
Since
4.0.0
Returns
array
Exceptions
DALExceptionIf DSN not configured.

Definition at line 1508 of file DAL.inc.

static getDsnFromConfig (   $conn_id)
static

Gets the DSN array for the specified connection ID from the DAL configuration.

Parameters
string$conn_idConnection ID to get details from.
Since
4.0.0
Returns
array
Exceptions
DALExceptionIf DSN not configured.

Definition at line 1536 of file DAL.inc.

static getExecuteAll (   $systemid,
  $queryid 
)
static

Alias for executeAll.

Parameters
string$systemidSystem's ID.
string$queryidID of the SQL query.
Since
4.0.0
Returns
integer

Definition at line 538 of file DAL.inc.

static getExecuteQuery (   $systemid,
  $queryid = NULL 
)
static

Alias for executeQuery.

Parameters
string | object$systemidSystem's ID.
string$queryidID of the SQL query.
Since
4.0.0
Returns
integer

Definition at line 522 of file DAL.inc.

static getGrouped ( Query  $dalQuery)
static

Returns all rows grouped by first column.

Parameters
Query$dalQuerySQL Query to execute.
Since
4.0.0
Returns
array
Exceptions
DALExceptionIf query execution fails.

Definition at line 324 of file DAL.inc.

static getGroupedAssoc ( Query  $dalQuery)
static

Returns all rows grouped by first column, with subsequent fields keyed by their field name.

Parameters
Query$dalQuerySQL Query to execute.
Since
4.0.0
Returns
array
Exceptions
DALExceptionIf query execution fails.

Definition at line 346 of file DAL.inc.

static getLoggedQueries ( )
static

Returns list of logged queries.

Since
4.0.0
Returns
array

Definition at line 1832 of file DAL.inc.

static getOne ( Query  $dalQuery)
static

Returns a single value.

Parameters
Query$dalQuerySQL Query to execute.
Since
4.0.0
Returns
array

Definition at line 275 of file DAL.inc.

static getOvenPath (   $system = NULL)
static

Returns the oven dir path.

If system name is provided then, that system's oven dir will be returned.

Parameters
string$systemSystem name.
Since
4.0.0
Returns
string

Definition at line 1690 of file DAL.inc.

static getQuery (   $systemid,
  $queryid,
  $bindValues = TRUE 
)
static

Returns the PDO query object for the given system and queryid.

Parameters
string$systemidSystem name that the query belongs to.
string$queryidID of the query.
boolean$bindValuesIf TRUE, will add the query to a PDOStatement object and bind its' variables. Otherwise, it will return an array representation of it.
Since
4.0.0
Returns
object
Exceptions
DALExceptionIf failed to load the query.

Definition at line 199 of file DAL.inc.

static getQueryObject (   $id)
static

Returns the path to store query objects.

Parameters
string$idThe ID of the query to retrieve.
Since
4.0.0
Returns
Query
Exceptions
DALExceptionWhen object is not found.

Definition at line 1726 of file DAL.inc.

static getQueryStorePath ( )
static

Returns the path to store query objects.

Since
4.0.0
Returns
string

Definition at line 1709 of file DAL.inc.

static getSqlQueriesFromFile (   $path)
static

Split SQL quries that are in a file and seperated by "–$$".

Parameters
string$pathFile path of the SQL file.
Since
4.0.0
Returns
array

Definition at line 1750 of file DAL.inc.

static isDALQuery (   $query)
static

Returns TRUE if passed variable is a DAL query.

Parameters
mixed$queryVariable to test.
Since
4.0.0
Returns
boolean

Definition at line 1771 of file DAL.inc.

static lastInsertId (   $sequenceName)
static

Returns the ID of the last inserted row or sequence value.

!!!Remove this funcion!!!

Parameters
string$sequenceNameName of the sequence from which the ID should be returned.
Since
4.0.0
Returns
integer

Definition at line 1181 of file DAL.inc.

static query (   $sql)
static

Executes an SQL statement, returning a result set as a PDOStatement.

Parameters
string$sqlThe sql statement.
Since
4.0.0
Returns
PDOStatement

Definition at line 1073 of file DAL.inc.

static requireQueryClass (   $systemid)
static

Requires the queries class file for a system.

Parameters
string$systemidID of the system.
Since
4.0.0
Returns
void

Definition at line 1670 of file DAL.inc.

static restoreDb ( )
static

Restore database connection.

Since
4.0.0
Returns
void
Exceptions
DALExceptionIf the database connection stack is empty.

Definition at line 1378 of file DAL.inc.

static rollBack ( )
static

Rolls back a transaction in the current database.

All changes made since last commit will be lost.

Since
4.0.0
Returns
void

Definition at line 1147 of file DAL.inc.

static setOciCommitOnSuccess (   $switch)
static

Switch on/off oci_commit_on_success flag for executing oci queires Mainly used to avoid oracle + bulkmail fork end-of-communication issue In this mode, oci queries will be executed immediately

Parameters
booleanswitch on/off oci commit on success mode
Since
4.0.0
Returns
void

Definition at line 1861 of file DAL.inc.

static transactionSupport (   $conn_id = NULL)
static

Checks if the database supports transactions.

If PDO does not throw an exception when beginTransaction is called then transactions are supported.

Parameters
string$conn_idConnection ID to close.
Since
4.0.0
Returns
boolean

Definition at line 1424 of file DAL.inc.


The documentation for this class was generated from the following file: