
Static Public Member Functions | |
| static | cancelTransaction () |
| Cancel all transactions. | |
| static | cleanupTransactions () |
| Cancels any transactions still pending. | |
| static | commitTransaction () |
| Commit a transaction. | |
| static | connect ($user, $pass, $host, $db) |
| Connects to a database. | |
| static | criteriaToString ($arr, $attributes) |
| Converts criteria array to a string. | |
| static | disconnect () |
| INSERT BRIEF DESCRIPTION HERE. | |
| static | firstRow ($reset=false) |
| Returns first row of results. | |
| static | freeResult () |
| INSERT BRIEF DESCRIPTION HERE. | |
| static | getInsertId () |
| Returns primary key from last INSERT operation. | |
| static | getNumRows () |
| Returns number of rows in result set. | |
| static | getRow ($rowNum=false) |
| Returns a single row of results. | |
| static | limitToString ($limit) |
| Converts limit array to a string. | |
| static | orderToString ($order, $attributes) |
| Converts order array to string. | |
| static | query ($query, $getResult=false) |
| Query the database. | |
| static | startTransaction () |
| Start a transaction. | |
Static Private Attributes | |
| static | $CONN |
| static | $QUERY_COUNT |
| static | $RCOOKIE |
| static | $transLevel |
For internal use only.
This class implements many of the same features of our beloved old DBI, but it is tailored towards the usage needed by Snap2 and it also avoids overhead where not needed. One of the major extra features is that it supports database transactions, so that all Snap operations can be atomic.
Definition at line 13 of file SnapDBI.php5.
| static SnapDBI::cancelTransaction | ( | ) | [static] |
Cancel all transactions.
For internal use only.
If transactions are nested, a ROLLBACK query is still issued and the transaction nesting level is reduced to zero.
Definition at line 248 of file SnapDBI.php5.
References Snap2::checkInit().
Referenced by SnapPathCache::addPathSet(), SnapPermission::commit(), SnapMetadata::commit(), SnapResourceUserPermission::copy(), SnapResourceGroupPermission::copy(), SnapDirectoryUserPermission::copy(), SnapDirectoryGroupPermission::copy(), SnapDirectory::createDirectory(), SnapDirectory::createResource(), SnapResource::createVersion(), SnapPermission::doCommit(), SnapPermission::grantPrivilege(), SnapFile::recReparentPseudoOrphans(), SnapPathCache::regenPathCache(), SnapPathCache::removePathSet(), SnapFile::restore(), SnapPermission::revokePrivilege(), SnapContentMediaNetlogoApplet::updateFileList(), SnapContentMediaInteractivateApplet::updateFileList(), SnapContentMediaImage::updateFileList(), SnapContentMediaFile::updateFileList(), SnapContentMediaDocument::updateFileList(), SnapContentMediaAgentsheetsApplet::updateFileList(), and SnapPathCache::updatePathSet().
| static SnapDBI::cleanupTransactions | ( | ) | [static] |
Cancels any transactions still pending.
For internal use only.
This method is a shutdown function intended to prevent the database from getting locked up in a transaction if the script dies in the middle of a transaction. It is public because shutdown functions must be public.
Definition at line 81 of file SnapDBI.php5.
| static SnapDBI::commitTransaction | ( | ) | [static] |
Commit a transaction.
For internal use only.
If transaction nesting level is greater than 1, then this method is a no-op.
If a transaction fails to commit, then it's best for the script to bail instead of having a complex system to rollback any updates to objects and the cache, it makes more sense to simply treat all objects involved in the transaction as tainted and try to gracefully exit the script as soon as possible; in general, transactions should never fail unless there is a bug or a problem with the DB server
Definition at line 227 of file SnapDBI.php5.
References Snap2::checkInit().
Referenced by SnapPathCache::addPathSet(), SnapPermission::commit(), SnapMetadata::commit(), SnapResourceUserPermission::copy(), SnapResourceGroupPermission::copy(), SnapDirectoryUserPermission::copy(), SnapDirectoryGroupPermission::copy(), SnapDirectory::createDirectory(), SnapDirectory::createResource(), SnapPermission::grantPrivilege(), SnapPathCache::regenPathCache(), SnapPathCache::removePathSet(), SnapFile::restore(), SnapPermission::revokePrivilege(), SnapContentMediaNetlogoApplet::updateFileList(), SnapContentMediaInteractivateApplet::updateFileList(), SnapContentMediaImage::updateFileList(), SnapContentMediaFile::updateFileList(), SnapContentMediaDocument::updateFileList(), SnapContentMediaAgentsheetsApplet::updateFileList(), and SnapPathCache::updatePathSet().
| static SnapDBI::connect | ( | $ | user, | |
| $ | pass, | |||
| $ | host, | |||
| $ | db | |||
| ) | [static] |
Connects to a database.
For internal use only.
| $user | [string]: username of DB user | |
| $pass | [string]: password for user | |
| $host | [string]: database server host | |
| $db | [string]: database name |
Definition at line 36 of file SnapDBI.php5.
Referenced by Snap2::init(), and Snap2::reinit().
| static SnapDBI::criteriaToString | ( | $ | arr, | |
| $ | attributes | |||
| ) | [static] |
Converts criteria array to a string.
For internal use only.
See the SWAT Model2 documentation on the wiki for more about the structure of this array
| $arr | [array]: criteria array | |
| $attributes | [array]: list of attributes that can be used in criteria array |
Definition at line 269 of file SnapDBI.php5.
Referenced by SnapMetadata::findKeys(), and SnapDirectory::listContents().
| static SnapDBI::disconnect | ( | ) | [static] |
INSERT BRIEF DESCRIPTION HERE.
INSERT FULL DESCRIPTION HERE
Definition at line 65 of file SnapDBI.php5.
Referenced by Snap2::reinit().
| static SnapDBI::firstRow | ( | $ | reset = false |
) | [static] |
Returns first row of results.
For internal use only.
| $reset | [boolean]: whether to reset to row 0 (usually not needed) |
Definition at line 161 of file SnapDBI.php5.
References Snap2::checkInit().
Referenced by SnapVersion::populate().
| static SnapDBI::freeResult | ( | ) | [static] |
INSERT BRIEF DESCRIPTION HERE.
INSERT FULL DESCRIPTION HERE
Definition at line 185 of file SnapDBI.php5.
References Snap2::checkInit().
Referenced by SnapPermissionCache::__construct(), SnapDirectory::canCreateDirectory(), SnapDirectory::canCreateResource(), SnapPermissionObject::getCapabilities(), SnapDirectory::listContents(), SnapBulkAction::listVersionsRecursive(), SnapPermission::loadParties(), SnapPermission::loadSpecialUsers(), SnapPermissionObject::populate(), SnapVersion::populate(), SnapPermissionObject::warmCache(), and SnapPermissionCache::warmCache().
| static SnapDBI::getInsertId | ( | ) | [static] |
Returns primary key from last INSERT operation.
For internal use only.
Definition at line 135 of file SnapDBI.php5.
References Snap2::checkInit().
Referenced by SnapDirectory::createDirectory(), and SnapDirectory::createResource().
| static SnapDBI::getNumRows | ( | ) | [static] |
Returns number of rows in result set.
For internal use only.
Definition at line 173 of file SnapDBI.php5.
References Snap2::checkInit().
Referenced by SnapDirectory::canCreateResource(), SnapPermission::loadSpecialUsers(), and SnapVersion::populate().
| static SnapDBI::getRow | ( | $ | rowNum = false |
) | [static] |
Returns a single row of results.
For internal use only.
| $rowNum | [integer]: index of row to retrieve, or false if retrieving "next" row |
Definition at line 146 of file SnapDBI.php5.
References Snap2::checkInit().
Referenced by SnapPermissionCache::__construct(), SnapPermissionObject::getCapabilities(), SnapDirectory::listContents(), SnapBulkAction::listVersionsRecursive(), SnapPermission::loadParties(), SnapPermission::loadSpecialUsers(), SnapPermissionObject::populate(), SnapPermissionObject::warmCache(), and SnapPermissionCache::warmCache().
| static SnapDBI::limitToString | ( | $ | limit | ) | [static] |
Converts limit array to a string.
For internal use only.
If limit is an array, the one or two elements are treated as the one or two arguments to the SQL 'LIMIT' qualifier. If limit is a number, then that single number is treated as the sole argument to the SQL 'LIMIT' qualifier.
| $limit | [array]: limit array |
Definition at line 391 of file SnapDBI.php5.
Referenced by SnapMetadata::findKeys(), and SnapDirectory::listContents().
| static SnapDBI::orderToString | ( | $ | order, | |
| $ | attributes | |||
| ) | [static] |
Converts order array to string.
For internal use only.
If $order is array, then each element indicates another sort column. If element is associative, the key is treated as the attribute and the value must be either 'ASC' or 'DESC'. If $order is a string, it is used as is.
| $order | [mixed]: order array or string | |
| $attributes | [array]: array of attributes that can be used in order array |
Definition at line 434 of file SnapDBI.php5.
Referenced by SnapMetadata::findKeys(), and SnapDirectory::listContents().
| static SnapDBI::query | ( | $ | query, | |
| $ | getResult = false | |||
| ) | [static] |
Query the database.
For internal use only.
This method has the feature of not retrieving any results unless asked for them. This way, the results can be gathered row by row instead of creating a giant array, only to loop over it again in calling code.
| $query | [string]: database query | |
| $getResult | [boolean]: whether to return a result array |
Definition at line 98 of file SnapDBI.php5.
References Snap2::checkInit().
Referenced by SnapPermissionCache::__construct(), SnapFile::_canMove(), SnapPathCache::addPathSet(), SnapDirectory::canCreateResource(), SnapPermission::commit(), SnapMetadata::commit(), SnapResourceUserPermission::copy(), SnapResourceGroupPermission::copy(), SnapDirectoryUserPermission::copy(), SnapDirectoryGroupPermission::copy(), SnapDirectory::createDirectory(), SnapDirectory::createResource(), SnapPermission::doCommit(), SnapSearch::execute(), SnapMetadata::findKeys(), SnapPermissionObject::getCapabilities(), SnapPermission::grantPrivilege(), SnapDirectory::listContents(), SnapBulkAction::listVersionsRecursive(), SnapDirectory::loadMaxDirOrdinal(), SnapResource::loadMaxOrdinal(), SnapDirectory::loadMaxResOrdinal(), SnapPermission::loadParties(), SnapPermission::loadSpecialUsers(), SnapPermissionObject::populate(), SnapVersion::populate(), SnapMetadata::populate(), SnapFile::populate(), SnapPathCache::recRegenDirectory(), SnapPathCache::recRegenResource(), SnapPathCache::regenPathCache(), SnapPathCache::removePathSet(), SnapFile::restore(), SnapPathCache::retrievePath(), SnapPermission::revokePrivilege(), SnapPathCache::updatePathSet(), SnapPermissionObject::warmCache(), and SnapPermissionCache::warmCache().
| static SnapDBI::startTransaction | ( | ) | [static] |
Start a transaction.
For internal use only.
If already in a transaction, then the transaction level variable is incremented, but no START TRANSACTION query is sent.
Definition at line 200 of file SnapDBI.php5.
References Snap2::checkInit().
Referenced by SnapPathCache::addPathSet(), SnapPermission::commit(), SnapMetadata::commit(), SnapResourceUserPermission::copy(), SnapResourceGroupPermission::copy(), SnapDirectoryUserPermission::copy(), SnapDirectoryGroupPermission::copy(), SnapDirectory::createDirectory(), SnapDirectory::createResource(), SnapPermission::grantPrivilege(), SnapVersion::logAction(), SnapFile::mklink(), SnapPathCache::regenPathCache(), SnapPathCache::removePathSet(), SnapFile::restore(), SnapPermission::revokePrivilege(), SnapFile::setName(), SnapResource::setValidDate(), SnapContentMediaNetlogoApplet::updateFileList(), SnapContentMediaInteractivateApplet::updateFileList(), SnapContentMediaImage::updateFileList(), SnapContentMediaFile::updateFileList(), SnapContentMediaDocument::updateFileList(), SnapContentMediaAgentsheetsApplet::updateFileList(), and SnapPathCache::updatePathSet().
SnapDBI::$CONN [static, private] |
Connection to MySQL database
Definition at line 15 of file SnapDBI.php5.
SnapDBI::$QUERY_COUNT [static, private] |
Number of queries performed so far (only used for debug statements)
Definition at line 19 of file SnapDBI.php5.
SnapDBI::$RCOOKIE [static, private] |
Cookie for last result from a query
Definition at line 17 of file SnapDBI.php5.
SnapDBI::$transLevel [static, private] |
How many levels of transaction nesting are we in?
Definition at line 22 of file SnapDBI.php5.
1.5.6