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

Public Member Functions

 __construct ()
 

Static Public Member Functions

static getQuery ($systemid, $queryid, $params=Array(), $bindValues=TRUE)
 
static executeGrouped ($systemid, $queryid, $params=Array())
 
static executeGroupedAssoc ($systemid, $queryid, $params=Array())
 
static executeAssoc ($systemid, $queryid, $col=NULL, $params=Array())
 
static executeAll ($systemid, $queryid, $params=Array())
 
static executeOne ($systemid, $queryid, $params=Array())
 
static executeQuery ($systemid, $queryid=NULL, $params=Array())
 
static preparePdoQuery ($sql)
 
static bindValueToPdo ($query, $name, $value, $dataType=NULL)
 
static bindValueToPdoByRef ($query, $name, &$value, $dataType=NULL, $maxLength=NULL)
 
static bindValuesToPdo ($query, $name, $value)
 
static quote ($value)
 
- Static Public Member Functions inherited from DAL
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 _getPdoDataType ($systemId, $table, $column, $dataType=NULL)
 
- Static Protected Member Functions inherited from DAL
static _startQueryTimer ($query)
 
static _endQueryTimer ()
 

Detailed Description

Definition at line 45 of file MatrixDAL.inc.

Constructor & Destructor Documentation

__construct ( )

Constructor

Definition at line 53 of file MatrixDAL.inc.

Member Function Documentation

static _getPdoDataType (   $systemId,
  $table,
  $column,
  $dataType = NULL 
)
staticprotected

Retrieves the PDO data type for a column.

Used when printing bindings for queries.

Parameters
string$systemIdSystem the column is from.
string$tableTable the column is in.
string$columnThe column name.
string$dataTypeThe datatype to bind this value with. Will override any other value.
Since
4.0.0
Returns
string

Definition at line 417 of file MatrixDAL.inc.

static bindValuesToPdo (   $query,
  $name,
  $value 
)
static

Bind more than one variable to a PDO statement.

Returns
void public

Definition at line 397 of file MatrixDAL.inc.

static bindValueToPdo (   $query,
  $name,
  $value,
  $dataType = NULL 
)
static

Bind a single variable to a PDO statement.

Bind variables are to be specified WITHOUT the leading ":". This is a change from binding directly to a PDO statement, but this keeps consistency with binding to DAL query objects.

Note that this function accepts both PDO and OCI8 statements - prepared using preparePdoQuery(), one would hope. When Oracle support is better in PDO, this function can remain, but only using the PDO functions. This allows the preparation of statements to only require DAL.

Parameters
object | resource$queryA PDO or OCI8 statement to bind to.
string$nameName of the bind variable.
Returns
void public

Definition at line 308 of file MatrixDAL.inc.

static bindValueToPdoByRef (   $query,
  $name,
$value,
  $dataType = NULL,
  $maxLength = NULL 
)
static

Bind a single variable to a PDO statement.

Bind variables are to be specified WITHOUT the leading ":". This is a change from binding directly to a PDO statement, but this keeps consistency with binding to DAL query objects.

Note that this function accepts both PDO and OCI8 statements - prepared using preparePdoQuery(), one would hope. When Oracle support is better in PDO, this function can remain, but only using the PDO functions. This allows the preparation of statements to only require DAL.

Parameters
object | resource$queryA PDO or OCI8 statement to bind to.
string$nameName of the bind variable.
Returns
void public

Definition at line 356 of file MatrixDAL.inc.

static executeAll (   $systemid,
  $queryid,
  $params = Array() 
)
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 168 of file MatrixDAL.inc.

static executeAssoc (   $systemid,
  $queryid,
  $col = NULL,
  $params = Array() 
)
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 143 of file MatrixDAL.inc.

static executeGrouped (   $systemid,
  $queryid,
  $params = Array() 
)
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 106 of file MatrixDAL.inc.

static executeGroupedAssoc (   $systemid,
  $queryid,
  $params = Array() 
)
static

Returns all rows grouped by first column, columns keyed by field name.

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

Definition at line 123 of file MatrixDAL.inc.

static executeOne (   $systemid,
  $queryid,
  $params = Array() 
)
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 187 of file MatrixDAL.inc.

static executeQuery (   $systemid,
  $queryid = NULL,
  $params = Array() 
)
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 216 of file MatrixDAL.inc.

static getQuery (   $systemid,
  $queryid,
  $params = Array(),
  $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.
array$paramsParameters for 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 76 of file MatrixDAL.inc.

static preparePdoQuery (   $sql)
static

Prepare SQL into a query statement.

This function is being provided to provide a central point for queries to be prepared to be sent to the executePdo* functions. This is currently different in Oracle to the other DBs, as Oracle support in PDO is not up to scratch - so we return an OCI8 statement resource instead.

When Oracle support is better in PDO, this function can remain, but only using the PDO functions. This allows the preparation of statements to only require DAL, rather than explicitly getting the database.

Returns
mixed object|resource public

Definition at line 273 of file MatrixDAL.inc.

static quote (   $value)
static

Wrapper function for safe quoting.

Use of this function is discouraged - binding queries should be used where possible. However, there are some places where it is difficult to unravel old habits in Matrix. Manually wrapping in single quotes without escaping the function inside is unsafe, hence this function to replace PDO's quote() function, which fails in Oracle (and is not relevant in OCI8 functions anyway).

This alternate quoting should be safe for both Oracle and PostgreSQL, although it will only be used (in Matrix) by the former.

Parameters
mixed$valueThe value to safely quote.
Returns
string

Definition at line 463 of file MatrixDAL.inc.


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