当前位置: 首页>>代码示例>>PHP>>正文


PHP DatabaseBase::rollback方法代码示例

本文整理汇总了PHP中DatabaseBase::rollback方法的典型用法代码示例。如果您正苦于以下问题:PHP DatabaseBase::rollback方法的具体用法?PHP DatabaseBase::rollback怎么用?PHP DatabaseBase::rollback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DatabaseBase的用法示例。


在下文中一共展示了DatabaseBase::rollback方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createTables

 /**
  * Create database tables from scratch.
  *
  * @return Status
  */
 public function createTables()
 {
     $status = $this->getConnection();
     if (!$status->isOK()) {
         return $status;
     }
     $this->db->selectDB($this->getVar('wgDBname'));
     if ($this->db->tableExists('archive', __METHOD__)) {
         $status->warning('config-install-tables-exist');
         $this->enableLB();
         return $status;
     }
     $this->db->setFlag(DBO_DDLMODE);
     // For Oracle's handling of schema files
     $this->db->begin(__METHOD__);
     $error = $this->db->sourceFile($this->db->getSchemaPath());
     if ($error !== true) {
         $this->db->reportQueryError($error, 0, '', __METHOD__);
         $this->db->rollback(__METHOD__);
         $status->fatal('config-install-tables-failed', $error);
     } else {
         $this->db->commit(__METHOD__);
     }
     // Resume normal operations
     if ($status->isOk()) {
         $this->enableLB();
     }
     return $status;
 }
开发者ID:Grprashanthkumar,项目名称:ColfusionWeb,代码行数:34,代码来源:DatabaseInstaller.php

示例2: tearDown

 protected function tearDown()
 {
     wfProfileIn(__METHOD__);
     // Cleaning up temporary files
     foreach ($this->tmpfiles as $fname) {
         if (is_file($fname) || is_link($fname)) {
             unlink($fname);
         } elseif (is_dir($fname)) {
             wfRecursiveRemoveDir($fname);
         }
     }
     if ($this->needsDB() && $this->db) {
         // Clean up open transactions
         while ($this->db->trxLevel() > 0) {
             $this->db->rollback();
         }
         // don't ignore DB errors
         $this->db->ignoreErrors(false);
     }
     // Restore mw globals
     foreach ($this->mwGlobals as $key => $value) {
         $GLOBALS[$key] = $value;
     }
     $this->mwGlobals = array();
     $phpErrorLevel = intval(ini_get('error_reporting'));
     if ($phpErrorLevel !== $this->phpErrorLevel) {
         ini_set('error_reporting', $this->phpErrorLevel);
         $oldHex = strtoupper(dechex($this->phpErrorLevel));
         $newHex = strtoupper(dechex($phpErrorLevel));
         $message = "PHP error_reporting setting was left dirty: was 0x{$oldHex} before test, 0x{$newHex} after test!";
         $this->fail($message);
     }
     parent::tearDown();
     wfProfileOut(__METHOD__);
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:35,代码来源:MediaWikiTestCase.php

示例3: createExtensionTables

 /**
  * Create the tables for each extension the user enabled
  * @return Status
  */
 public function createExtensionTables()
 {
     $status = $this->getConnection();
     if (!$status->isOK()) {
         return $status;
     }
     $updater = DatabaseUpdater::newForDB($this->db);
     $extensionUpdates = $updater->getNewExtensions();
     $ourExtensions = array_map('strtolower', $this->getVar('_Extensions'));
     foreach ($ourExtensions as $ext) {
         if (isset($extensionUpdates[$ext])) {
             $this->db->begin(__METHOD__);
             $error = $this->db->sourceFile($extensionUpdates[$ext]);
             if ($error !== true) {
                 $this->db->rollback(__METHOD__);
                 $status->warning('config-install-tables-failed', $error);
             } else {
                 $this->db->commit(__METHOD__);
             }
         }
     }
     // Now run updates to create tables for old extensions
     $updater->doUpdates(array('extensions'));
     return $status;
 }
开发者ID:GodelDesign,项目名称:Godel,代码行数:29,代码来源:DatabaseInstaller.php

示例4: stepApplySourceFile

 /**
  * Apply a SQL source file to the database as part of running an installation step.
  *
  * @param string $sourceFileMethod
  * @param string $stepName
  * @param string $archiveTableMustNotExist
  * @return Status
  */
 private function stepApplySourceFile($sourceFileMethod, $stepName, $archiveTableMustNotExist = false)
 {
     $status = $this->getConnection();
     if (!$status->isOK()) {
         return $status;
     }
     $this->db->selectDB($this->getVar('wgDBname'));
     if ($archiveTableMustNotExist && $this->db->tableExists('archive', __METHOD__)) {
         $status->warning("config-{$stepName}-tables-exist");
         $this->enableLB();
         return $status;
     }
     $this->db->setFlag(DBO_DDLMODE);
     // For Oracle's handling of schema files
     $this->db->begin(__METHOD__);
     $error = $this->db->sourceFile(call_user_func(array($this->db, $sourceFileMethod)));
     if ($error !== true) {
         $this->db->reportQueryError($error, 0, '', __METHOD__);
         $this->db->rollback(__METHOD__);
         $status->fatal("config-{$stepName}-tables-failed", $error);
     } else {
         $this->db->commit(__METHOD__);
     }
     // Resume normal operations
     if ($status->isOk()) {
         $this->enableLB();
     }
     return $status;
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:37,代码来源:DatabaseInstaller.php

示例5: tearDown

 protected function tearDown()
 {
     wfProfileIn(__METHOD__);
     // Cleaning up temporary files
     foreach ($this->tmpfiles as $fname) {
         if (is_file($fname) || is_link($fname)) {
             unlink($fname);
         } elseif (is_dir($fname)) {
             wfRecursiveRemoveDir($fname);
         }
     }
     if ($this->needsDB() && $this->db) {
         // Clean up open transactions
         while ($this->db->trxLevel() > 0) {
             $this->db->rollback();
         }
         // don't ignore DB errors
         $this->db->ignoreErrors(false);
     }
     // Restore mw globals
     foreach ($this->mwGlobals as $key => $value) {
         $GLOBALS[$key] = $value;
     }
     $this->mwGlobals = array();
     parent::tearDown();
     wfProfileOut(__METHOD__);
 }
开发者ID:mangowi,项目名称:mediawiki,代码行数:27,代码来源:MediaWikiTestCase.php

示例6: tearDown

 protected function tearDown()
 {
     $this->called['tearDown'] = true;
     // Cleaning up temporary files
     foreach ($this->tmpFiles as $fileName) {
         if (is_file($fileName) || is_link($fileName)) {
             unlink($fileName);
         } elseif (is_dir($fileName)) {
             wfRecursiveRemoveDir($fileName);
         }
     }
     if ($this->needsDB() && $this->db) {
         // Clean up open transactions
         while ($this->db->trxLevel() > 0) {
             $this->db->rollback();
         }
     }
     // Restore mw globals
     foreach ($this->mwGlobals as $key => $value) {
         $GLOBALS[$key] = $value;
     }
     $this->mwGlobals = array();
     RequestContext::resetMain();
     MediaHandler::resetCache();
     $phpErrorLevel = intval(ini_get('error_reporting'));
     if ($phpErrorLevel !== $this->phpErrorLevel) {
         ini_set('error_reporting', $this->phpErrorLevel);
         $oldHex = strtoupper(dechex($this->phpErrorLevel));
         $newHex = strtoupper(dechex($phpErrorLevel));
         $message = "PHP error_reporting setting was left dirty: " . "was 0x{$oldHex} before test, 0x{$newHex} after test!";
         $this->fail($message);
     }
     parent::tearDown();
 }
开发者ID:nanasess,项目名称:mediawiki,代码行数:34,代码来源:MediaWikiTestCase.php

示例7: tearDown

 protected function tearDown()
 {
     global $wgRequest;
     $status = ob_get_status();
     if (isset($status['name']) && $status['name'] === 'MediaWikiTestCase::wfResetOutputBuffersBarrier') {
         ob_end_flush();
     }
     $this->called['tearDown'] = true;
     // Cleaning up temporary files
     foreach ($this->tmpFiles as $fileName) {
         if (is_file($fileName) || is_link($fileName)) {
             unlink($fileName);
         } elseif (is_dir($fileName)) {
             wfRecursiveRemoveDir($fileName);
         }
     }
     if ($this->needsDB() && $this->db) {
         // Clean up open transactions
         while ($this->db->trxLevel() > 0) {
             $this->db->rollback(__METHOD__, 'flush');
         }
     }
     // Restore mw globals
     foreach ($this->mwGlobals as $key => $value) {
         $GLOBALS[$key] = $value;
     }
     $this->mwGlobals = [];
     $this->restoreLoggers();
     if (self::$serviceLocator && MediaWikiServices::getInstance() !== self::$serviceLocator) {
         MediaWikiServices::forceGlobalInstance(self::$serviceLocator);
     }
     // TODO: move global state into MediaWikiServices
     RequestContext::resetMain();
     MediaHandler::resetCache();
     if (session_id() !== '') {
         session_write_close();
         session_id('');
     }
     $wgRequest = new FauxRequest();
     MediaWiki\Session\SessionManager::resetCache();
     MediaWiki\Auth\AuthManager::resetCache();
     $phpErrorLevel = intval(ini_get('error_reporting'));
     if ($phpErrorLevel !== $this->phpErrorLevel) {
         ini_set('error_reporting', $this->phpErrorLevel);
         $oldHex = strtoupper(dechex($this->phpErrorLevel));
         $newHex = strtoupper(dechex($phpErrorLevel));
         $message = "PHP error_reporting setting was left dirty: " . "was 0x{$oldHex} before test, 0x{$newHex} after test!";
         $this->fail($message);
     }
     parent::tearDown();
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:51,代码来源:MediaWikiTestCase.php

示例8: tearDown

 protected function tearDown()
 {
     // Cleaning up temporary files
     foreach ($this->tmpfiles as $fname) {
         if (is_file($fname) || is_link($fname)) {
             unlink($fname);
         } elseif (is_dir($fname)) {
             wfRecursiveRemoveDir($fname);
         }
     }
     // clean up open transactions
     if ($this->needsDB() && $this->db) {
         while ($this->db->trxLevel() > 0) {
             $this->db->rollback();
         }
     }
     parent::tearDown();
 }
开发者ID:Jobava,项目名称:diacritice-meta-repo,代码行数:18,代码来源:MediaWikiTestCase.php

示例9: handleWriteError

 /**
  * Handle a DBQueryError which occurred during a write operation.
  */
 protected function handleWriteError(DBError $exception)
 {
     if ($exception instanceof DBConnectionError) {
         $this->connFailureTime = time();
         $this->connFailureError = $exception;
     }
     if ($this->db && $this->db->wasReadOnlyError()) {
         try {
             $this->db->rollback(__METHOD__);
         } catch (DBError $e) {
         }
     }
     wfDebugLog('SQLBagOStuff', "DBError: {$exception->getMessage()}");
     if ($this->db) {
         wfDebug(__METHOD__ . ": ignoring query error\n");
     } else {
         wfDebug(__METHOD__ . ": ignoring connection error\n");
     }
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:22,代码来源:SqlBagOStuff.php

示例10: startWrite

 public function startWrite($code)
 {
     if ($this->readOnly) {
         return;
     }
     if (!$code) {
         throw new MWException(__METHOD__ . ": Invalid language \"{$code}\"");
     }
     $this->dbw = wfGetDB(DB_MASTER);
     try {
         $this->dbw->begin(__METHOD__);
         $this->dbw->delete('l10n_cache', array('lc_lang' => $code), __METHOD__);
     } catch (DBQueryError $e) {
         if ($this->dbw->wasReadOnlyError()) {
             $this->readOnly = true;
             $this->dbw->rollback(__METHOD__);
             return;
         } else {
             throw $e;
         }
     }
     $this->currentLang = $code;
     $this->batch = array();
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:24,代码来源:LocalisationCache.php

示例11: doBatchPushInternal

 /**
  * This function should *not* be called outside of JobQueueDB
  *
  * @param DatabaseBase $dbw
  * @param array $jobs
  * @param int $flags
  * @param string $method
  * @return boolean
  * @throws type
  */
 public function doBatchPushInternal(DatabaseBase $dbw, array $jobs, $flags, $method)
 {
     if (!count($jobs)) {
         return true;
     }
     $rowSet = array();
     // (sha1 => job) map for jobs that are de-duplicated
     $rowList = array();
     // list of jobs for jobs that are are not de-duplicated
     foreach ($jobs as $job) {
         $row = $this->insertFields($job);
         if ($job->ignoreDuplicates()) {
             $rowSet[$row['job_sha1']] = $row;
         } else {
             $rowList[] = $row;
         }
     }
     if ($flags & self::QOS_ATOMIC) {
         $dbw->begin($method);
         // wrap all the job additions in one transaction
     }
     try {
         // Strip out any duplicate jobs that are already in the queue...
         if (count($rowSet)) {
             $res = $dbw->select('job', 'job_sha1', array('job_sha1' => array_keys($rowSet), 'job_token' => ''), $method);
             foreach ($res as $row) {
                 wfDebug("Job with hash '{$row->job_sha1}' is a duplicate.\n");
                 unset($rowSet[$row->job_sha1]);
                 // already enqueued
             }
         }
         // Build the full list of job rows to insert
         $rows = array_merge($rowList, array_values($rowSet));
         // Insert the job rows in chunks to avoid slave lag...
         foreach (array_chunk($rows, 50) as $rowBatch) {
             $dbw->insert('job', $rowBatch, $method);
         }
         JobQueue::incrStats('job-insert', $this->type, count($rows));
         JobQueue::incrStats('job-insert-duplicate', $this->type, count($rowSet) + count($rowList) - count($rows));
     } catch (DBError $e) {
         if ($flags & self::QOS_ATOMIC) {
             $dbw->rollback($method);
         }
         throw $e;
     }
     if ($flags & self::QOS_ATOMIC) {
         $dbw->commit($method);
     }
     $this->cache->set($this->getCacheKey('empty'), 'false', JobQueueDB::CACHE_TTL_LONG);
     return true;
 }
开发者ID:mangowi,项目名称:mediawiki,代码行数:61,代码来源:JobQueueDB.php


注:本文中的DatabaseBase::rollback方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。