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


PHP DatabaseBase::begin方法代码示例

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


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

示例1: write

 /**
  * @param array $updates Array of arrays each containing two keys, 'primaryKey'
  *  and 'changes'. primaryKey must contain a map of column names to values
  *  sufficient to uniquely identify the row changes must contain a map of column
  *  names to update values to apply to the row.
  */
 public function write(array $updates)
 {
     $this->db->begin();
     foreach ($updates as $update) {
         $this->db->update($this->table, $update['changes'], $update['primaryKey'], __METHOD__);
     }
     $this->db->commit();
     wfWaitForSlaves(false, false, $this->clusterName);
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:15,代码来源:BatchRowWriter.php

示例2: 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

示例3: fixTemplate

 /**
  * fixTemplate
  *
  * This code ensures that the version of the Template that was in existence
  * at the same time as the Memento gets loaded and displayed with the
  * Memento.
  *
  * @fixme make this compatible with parser cache
  * @param Title $title
  * @param Parser $parser
  * @param integer $id
  *
  * @return array containing the text, finalTitle, and deps
  */
 public function fixTemplate(Title $title, Parser $parser, &$id)
 {
     // stopgap measure until we can find a better way
     // to work with parser cache
     $parser->disableCache();
     $request = $parser->getUser()->getRequest();
     if ($request->getHeader('ACCEPT-DATETIME')) {
         $requestDatetime = $request->getHeader('ACCEPT-DATETIME');
         $mwMementoTimestamp = $this->parseRequestDateTime($requestDatetime);
         $firstRev = $title->getFirstRevision();
         // if the template no longer exists, return gracefully
         if ($firstRev != null) {
             if ($firstRev->getTimestamp() < $mwMementoTimestamp) {
                 $pgID = $title->getArticleID();
                 $this->db->begin();
                 $res = $this->db->selectRow('revision', array('rev_id'), array('rev_page' => $pgID, 'rev_timestamp <=' . $this->db->addQuotes($mwMementoTimestamp)), __METHOD__, array('ORDER BY' => 'rev_id DESC', 'LIMIT' => '1'));
                 $id = $res->rev_id;
             } else {
                 // if we get something prior to the first memento, just
                 // go with the first one
                 $id = $firstRev->getId();
             }
         }
     }
 }
开发者ID:NDKilla,项目名称:memento,代码行数:39,代码来源:MementoResource.php

示例4: doUpdates

 /**
  * Do all the updates
  *
  * @param array $what what updates to perform
  */
 public function doUpdates($what = array('core', 'extensions', 'stats'))
 {
     global $wgVersion, $wgLocalisationCacheConf;
     $this->db->begin(__METHOD__);
     $what = array_flip($what);
     $this->skipSchema = isset($what['noschema']) || $this->fileHandle !== null;
     if (isset($what['core'])) {
         $this->runUpdates($this->getCoreUpdateList(), false);
     }
     if (isset($what['extensions'])) {
         $this->runUpdates($this->getOldGlobalUpdates(), false);
         $this->runUpdates($this->getExtensionUpdates(), true);
     }
     if (isset($what['stats'])) {
         $this->checkStats();
     }
     if (isset($what['purge'])) {
         $this->purgeCache();
         if ($wgLocalisationCacheConf['manualRecache']) {
             $this->rebuildLocalisationCache();
         }
     }
     $this->setAppliedUpdates($wgVersion, $this->updates);
     if ($this->fileHandle) {
         $this->skipSchema = false;
         $this->writeSchemaUpdateFile();
         $this->setAppliedUpdates("{$wgVersion}-schema", $this->updatesSkipped);
     }
     $this->db->commit(__METHOD__);
 }
开发者ID:mangowi,项目名称:mediawiki,代码行数:35,代码来源:DatabaseUpdater.php

示例5: 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

示例6: 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

示例7: mergePage

 /**
  * Merge page histories
  *
  * @param integer $id The page_id
  * @param Title $newTitle The new title
  */
 private function mergePage($row, Title $newTitle)
 {
     $id = $row->page_id;
     // Construct the WikiPage object we will need later, while the
     // page_id still exists. Note that this cannot use makeTitleSafe(),
     // we are deliberately constructing an invalid title.
     $sourceTitle = Title::makeTitle($row->page_namespace, $row->page_title);
     $sourceTitle->resetArticleID($id);
     $wikiPage = new WikiPage($sourceTitle);
     $wikiPage->loadPageData('fromdbmaster');
     $destId = $newTitle->getArticleId();
     $this->db->begin(__METHOD__);
     $this->db->update('revision', array('rev_page' => $destId), array('rev_page' => $id), __METHOD__);
     $this->db->delete('page', array('page_id' => $id), __METHOD__);
     /* Call LinksDeletionUpdate to delete outgoing links from the old title,
      * and update category counts.
      *
      * Calling external code with a fake broken Title is a fairly dubious
      * idea. It's necessary because it's quite a lot of code to duplicate,
      * but that also makes it fragile since it would be easy for someone to
      * accidentally introduce an assumption of title validity to the code we
      * are calling.
      */
     $update = new LinksDeletionUpdate($wikiPage);
     $update->doUpdate();
     $this->db->commit(__METHOD__);
     return true;
 }
开发者ID:Acidburn0zzz,项目名称:mediawiki,代码行数:34,代码来源:namespaceDupes.php

示例8: mergePage

 /**
  * Merge page histories
  *
  * @param integer $id The page_id
  * @param Title $newTitle The new title
  */
 private function mergePage($id, Title $newTitle)
 {
     $destId = $newTitle->getArticleId();
     $this->db->begin(__METHOD__);
     $this->db->update('revision', array('rev_page' => $destId), array('rev_page' => $id), __METHOD__);
     $this->db->delete('page', array('page_id' => $id), __METHOD__);
     // @fixme Need WikiPage::doDeleteUpdates() or similar to avoid orphan
     // rows in the links tables.
     $this->db->commit(__METHOD__);
     return true;
 }
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:17,代码来源:namespaceDupes.php

示例9: removeBatch

 /**
  * Remove a batch of users
  *
  * @param DatabaseBase $dbw
  * @param int[] $batch list of user IDs to remove
  */
 private function removeBatch(DatabaseBase $dbw, array $batch)
 {
     $rows = 0;
     $dbw->begin(__METHOD__);
     // remove entries from user table
     $dbw->delete(self::USER_TABLE, ['user_id' => $batch], __METHOD__);
     $rows += $dbw->affectedRows();
     // remove entries from user_properties table
     $dbw->delete('user_properties', ['up_user' => $batch], __METHOD__);
     $rows += $dbw->affectedRows();
     $dbw->commit(__METHOD__);
     $this->info('Batch removed', ['batch' => count($batch), 'rows' => $rows]);
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:19,代码来源:RemoveUserBase.class.php

示例10: doUpdates

 /**
  * Do all the updates
  *
  * @param $what Array: what updates to perform
  */
 public function doUpdates($what = array('core', 'extensions', 'stats'))
 {
     global $wgVersion;
     $this->db->begin(__METHOD__);
     $what = array_flip($what);
     if (isset($what['core'])) {
         $this->runUpdates($this->getCoreUpdateList(), false);
     }
     if (isset($what['extensions'])) {
         $this->runUpdates($this->getOldGlobalUpdates(), false);
         $this->runUpdates($this->getExtensionUpdates(), true);
     }
     $this->setAppliedUpdates($wgVersion, $this->updates);
     if (isset($what['stats'])) {
         $this->checkStats();
     }
     $this->db->commit(__METHOD__);
 }
开发者ID:nischayn22,项目名称:mediawiki-core,代码行数:23,代码来源:DatabaseUpdater.php

示例11: doUpdates

 /**
  * Do all the updates
  *
  * @param $what Array: what updates to perform
  */
 public function doUpdates($what = array('core', 'extensions', 'purge', 'stats'))
 {
     global $wgLocalisationCacheConf, $wgVersion;
     $this->db->begin(__METHOD__);
     $what = array_flip($what);
     if (isset($what['core'])) {
         $this->runUpdates($this->getCoreUpdateList(), false);
     }
     if (isset($what['extensions'])) {
         $this->runUpdates($this->getOldGlobalUpdates(), false);
         $this->runUpdates($this->getExtensionUpdates(), true);
     }
     $this->setAppliedUpdates($wgVersion, $this->updates);
     if (isset($what['stats'])) {
         $this->checkStats();
     }
     if (isset($what['purge'])) {
         $this->purgeCache();
         if ($wgLocalisationCacheConf['manualRecache']) {
             $this->rebuildLocalisationCache();
         }
     }
     $this->db->commit(__METHOD__);
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:29,代码来源:DatabaseUpdater.php

示例12: __construct

 /**
  * @param DatabaseBase $dbw
  * @param int $id
  */
 public function __construct($dbw, $id)
 {
     $this->dbw = $dbw;
     $this->id = $id;
     $this->didbegin = false;
     /* If we are not in a transaction, we need to be for savepoint trickery */
     if (!$dbw->trxLevel()) {
         $dbw->begin("FOR SAVEPOINT");
         $this->didbegin = true;
     }
 }
开发者ID:admonkey,项目名称:mediawiki,代码行数:15,代码来源:DatabasePostgres.php

示例13: 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

示例14: finishWrite

 public function finishWrite()
 {
     if ($this->readOnly) {
         return;
     } elseif (is_null($this->currentLang)) {
         throw new MWException(__CLASS__ . ': must call startWrite() before finishWrite()');
     }
     $this->dbw->begin(__METHOD__);
     try {
         $this->dbw->delete('l10n_cache', array('lc_lang' => $this->currentLang), __METHOD__);
         foreach (array_chunk($this->batch, 500) as $rows) {
             $this->dbw->insert('l10n_cache', $rows, __METHOD__);
         }
         $this->writesDone = true;
     } catch (DBQueryError $e) {
         if ($this->dbw->wasReadOnlyError()) {
             $this->readOnly = true;
             // just avoid site down time
         } else {
             throw $e;
         }
     }
     $this->dbw->commit(__METHOD__);
     $this->currentLang = null;
     $this->batch = array();
 }
开发者ID:jpena88,项目名称:mediawiki-dokku-deploy,代码行数:26,代码来源:LocalisationCache.php

示例15: writePropsToDB

 /**
  * Write (insert) the properties into the DB.
  *
  * @since 1.2
  *
  * @param Database $dbw
  *
  * @return boolean Success indicator
  */
 protected function writePropsToDB(DatabaseBase $dbw)
 {
     $success = true;
     if (array_key_exists('defaultOwnWorkLicence', $this->config) && array_key_exists('licensesOwnWork', $this->config) && !in_array($this->config['defaultOwnWorkLicence'], $this->config['licensesOwnWork'])) {
         $this->config['licensesOwnWork'][] = $this->config['defaultOwnWorkLicence'];
     }
     $dbw->begin();
     // TODO: it'd be better to serialize() arrays
     foreach ($this->config as $prop => $value) {
         $success &= $dbw->insert('uw_campaign_conf', array('cc_campaign_id' => $this->id, 'cc_property' => $prop, 'cc_value' => is_array($value) ? implode('|', $value) : $value), __METHOD__);
     }
     $dbw->commit();
     return $success;
 }
开发者ID:JeroenDeDauw,项目名称:UploadWizard,代码行数:23,代码来源:UploadWizardCampaign.php


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