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

Public Member Functions

 __construct ()
 

Static Public Member Functions

static addCoreQueries ()
 
static addPackageQueries ($package)
 
static addAssetTypeQueries ($assetType)
 
static bakeQueriesFile ($systemName)
 
static bakeQueryMethod ($systemName, $queryName)
 
static findRollbackBindVars ($queryBody)
 
static processQueriesFile ($systemName, $fileName)
 
- Static Public Member Functions inherited from DALBaker
static getSystemSchemaDocument ($systemName)
 
static addSystemSchema ($systemName)
 
static addSystemQueries ($systemName)
 
static processQueriesFile ($systemName, $fileName)
 
static mergeQuery ($systemName, $queryName)
 
static generateQueryXML ($systemName, $queryName)
 
static queryXMLExists ($systemName, $queryName)
 
static getQueryXML ($systemName, $queryName)
 
static saveQueryXML ($system, $queryName, DomDocument $doc)
 
static addQuery ($systemName, DomElement $query)
 
static addQueryFragment ($systemName, DomElement $fragment)
 
static addSubQuery ($systemName, DomElement $subQuery)
 
static bakeQueriesFile ($systemName)
 
static bakeQueryMethod ($systemName, $queryName)
 
static printSubQueries ($systemName, $queryName)
 
static getHookCodeId ($hookId)
 
static getHookArrayId ($hookId)
 
static getSeperator ($tagName)
 
static parseSchema (DomElement $schema)
 
static validateQueries (DomElement $queries)
 
static queryIdIsUnique (DomDocument $doc, DomElement $query)
 
static validateQuery (DomElement $query)
 
static getQueryType (DomElement $query)
 
static fragmentExists ($system, $queryid, $hookid)
 
static convertToSql (DomElement $xmlQuery, array $sqlArray=array())
 
static getConverter ($dbType=NULL)
 
static getTableColumnTypes ($systemid, $table, $column=NULL)
 
static getQuerySource ($systemid, $queryid)
 
static createSystemOvenPath ($system)
 
static loadQueriesXML ($systemid)
 
static getBakedQueryFileName ($systemid, $queryid)
 
static loadBakedQuery ($systemid, $queryid)
 
static loadSystemSchemaXML ($systemid)
 
static constructSql (DomElement $query)
 
static getHookPrefix ()
 
static getComparisonOperators ($type=NULL)
 
static getDatabaseType ($dsn=NULL)
 

Static Protected Member Functions

static _printBindings ($systemName, $queryName, $printBindings=TRUE)
 
static _queryRequiresRollback ($systemName, $queryName)
 
static _tableRequiresRollback ($table)
 
static _fieldRequiresOciClob ($table, $field)
 
static _createRollbackXML ($systemName, DOMNode $queryNode)
 
- Static Protected Member Functions inherited from DALBaker
static _dbDropTable ($tableName, DALConverter $converter=NULL)
 
static _dbTableExists ($tableName, DALConverter $converter=NULL)
 
static _printAlternateAssertions (DomElement $alternate, $contents)
 
static _recurseAddAssertion (array $assertions, array $currentStack=array())
 
static _recursePrintAssertions (array $tree, DomElement $baseQuery, $baseQueryId, $level=0)
 
static _mergeAllAssertions (DomElement $baseQuery, array $assertions)
 
static _getQueryAssertions ($systemName, $queryName)
 
static _getAssertionVariableName (DomElement $assertion)
 
static _combineFragment (DomElement $query, DomElement $fragment)
 
static _prepareFragment (DomElement $query)
 
static _printAssertionCalls (array $assertions)
 
static _printAssertionInitialisation (DomElement $assertion)
 
static _printAssertionArgument (DomElement $argNode)
 
static _printNodeSql (DomElement $query, $baseId='', array $idParts=array())
 
static _writeQueryObject ($id, array $sqlArray, $sql)
 
static _printPlaceHolderVariables ($systemName, $queryName)
 
static _generateHookArray ($systemName, $queryName)
 
static _printHookCode (array $hookIds)
 
static _printKeywords ($systemName, $queryName)
 
static _printBindings ($systemName, $queryName, $printBindings=TRUE)
 
static _extractBindings (DomElement $fragment)
 
static _extractKeywords (DomElement $fragment)
 
static _extractPlaceHolders (DomElement $fragment)
 
static _getPdoDataType ($systemId, $table, $column, $dataType=NULL)
 

Detailed Description

Definition at line 45 of file MatrixDALBaker.inc.

Constructor & Destructor Documentation

__construct ( )

Constructor

Definition at line 53 of file MatrixDALBaker.inc.

Member Function Documentation

static _createRollbackXML (   $systemName,
DOMNode  $queryNode 
)
staticprotected

Creates rollback XML for a query that requires a rollback version to be created.

Parameters
string$systemNameThe system to add queries to.
DOMNode$queryNodeThe DOM node containing the
Since
MySource 3.18.0 RC1
Returns
DOMNode

Definition at line 733 of file MatrixDALBaker.inc.

static _fieldRequiresOciClob (   $table,
  $field 
)
staticprotected

Determines from the MySource Matrix tables.xml schema whether a certain field is defined as a CLOB in Oracle.

This is necessary to know for Oracle, as there is an extra step that must be handled - a "LOB descriptor" must be made for a field, and then that descriptor is bound, rather than the field value itself.

Even when PDO works again, the query must be rewritten in a different way because of how Oracle handles LOB fields.

Parameters
string$tableThe table to be searched for.
string$fieldThe field to be searched for.
Since
MySource 3.18.0 RC2
Returns
boolean

Definition at line 561 of file MatrixDALBaker.inc.

static _printBindings (   $systemName,
  $queryName,
  $printBindings = TRUE 
)
staticprotected

Prints code to prepare the query and bind the placeholders to data.

This returns the code that is executed after the $sql variable is obtained from the assertion's conditions. The $dbh variable is initialised by getting the database connection from the DAL. Using the connection, the obtained $sql is prepared. All bindings are then obtained from the XML for the query. If they are a placeholder for a hard-coded value, then the placeholder is bound to the initialised variable, otherwise, the binding is done for an index into the passed $data array.

Parameters
string$systemNameThe system to print the bindings for.
string$queryNameThe query to print the bindings for.
boolean$printBindingsIf TRUE, will print bindings, otherwise will print entries into the query array.
Since
4.0.0
Returns
string

Definition at line 321 of file MatrixDALBaker.inc.

static _queryRequiresRollback (   $systemName,
  $queryName 
)
staticprotected

Determines from the MySource Matrix tables.xml schema(s) whether a query requires a rollback version to be generated for it.

This will be the case if any of the tables it uses requires a rollback table.

This function will only return a positive result for SELECT queries - queries that involve manipulation have their rollback actions covered by the trigger system. If the query is not a SELECT query, then there will be no tables found, and therefore this function will return in the negative.

TODO: need to check to see whether SELECT parts of INSERT...SELECT combination queries need this too - probably not, as you are very unlikely to have to add non-live data from another table.

TODO: need to implement SELECT sub-query checking for SELECT...SELECT situations.

Parameters
string$systemNameThe system to search for.
string$queryNameThe query to search for.
Since
MySource 3.18.0 RC1
Returns
boolean

Definition at line 453 of file MatrixDALBaker.inc.

static _tableRequiresRollback (   $table)
staticprotected

Determines from the MySource Matrix tables.xml schema whether a table requires a rollback table to be generated for it.

The core package will always be searched in, even if no packages (not even core) have been installed. This is due to the core package including the required tables for the core of MySource Matrix.

Parameters
string$tableThe table to be searched for.
Since
MySource 3.18.0 RC1
Returns
boolean

Definition at line 485 of file MatrixDALBaker.inc.

static addAssetTypeQueries (   $assetType)
static

Add queries for a certain MySource Matrix asset type.

These asset-type-level queries will be named the same as the asset type. Their queries.xml file lives in the "db" directory of the asset. Returns TRUE if the queries.xml file for an asset was found. The caller use the return to avoid baking queries for asset types without queries.

Parameters
string$assetTypeThe asset type code to be processed.
Since
MySource 3.18.0 RC1
Returns
boolean
Exceptions
DALBakerExceptionIf the asset has not yet been installed.

Definition at line 138 of file MatrixDALBaker.inc.

static addCoreQueries ( )
static

Add queries for the MySource Matrix core.

These core-level queries are necessary for operation of the core components of MySource Matrix (eg. those in the core/include, core/hipo, core/cron directories and so on). Its queries.xml file will live in a "core/db" directory underneath the Matrix system root. Returns TRUE if the queries.xml file for the core was found.

Since
MySource 3.18.0 RC1
Returns
boolean

Definition at line 72 of file MatrixDALBaker.inc.

static addPackageQueries (   $package)
static

Add queries for a certain MySource Matrix package.

These package-level queries will be named "[package_name]_package" and their queries.xml file lives in the root directory of the package. Returns TRUE if the queries.xml file for a package was found. The caller use the return to avoid baking queries for packages without queries.

Parameters
string$packageThe package to be processed.
Since
MySource 3.18.0 RC1
Returns
boolean
Exceptions
DALBakerExceptionIf the package has not yet been installed.

Definition at line 101 of file MatrixDALBaker.inc.

static bakeQueriesFile (   $systemName)
static

Bakes out a system's queries and business logic into PHP files.

Calls bakeQueryMethod() for each query that the system has defined. For the query to be baked correctly it is required that its' XML files have been created in the system's oven directory.

Parameters
string$systemNameName of the system to bake the code for.
Since
4.0.0
Returns
void
Exceptions
DALBakerExceptionIf the system name supplied is empty.

Definition at line 170 of file MatrixDALBaker.inc.

static bakeQueryMethod (   $systemName,
  $queryName 
)
static

Bakes out a method for a single query.

Reads in the XML files that have been generated for this query, gets all fragments and their assertions, and bakes out an appropriate method that will return an SQL statement that corresponds to the current system state and the systems currently installed.

Parameters
string$systemNameThe name of the system to which the query belongs.
string$queryNameThe name of the query to bake.
Since
4.0.0
Returns
string

Definition at line 221 of file MatrixDALBaker.inc.

static findRollbackBindVars (   $queryBody)
static

Find and returns the bind vars for rollback ie. "rbtime"

Parameters
string$queryBodyThe return from mergeQuery which contains the query information
Returns
array

Definition at line 280 of file MatrixDALBaker.inc.

static processQueriesFile (   $systemName,
  $fileName 
)
static

Processes a queries.xml file to prepare it for baking

Parameters
string$systemNameThe system to add queries to.
string$fileNameThe name of the queries file.
Since
4.0.0
Returns
void
Exceptions
DALBakerExceptionWhen an ID isn't specified for a query.

Definition at line 662 of file MatrixDALBaker.inc.


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