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


PHP DatabaseHandler::beginTransaction方法代码示例

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


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

示例1: purge

 /**
  * Remove entire search index.
  */
 public function purge()
 {
     $this->dbHandler->beginTransaction();
     $query = $this->dbHandler->createDeleteQuery();
     $tables = ['ezsearch_object_word_link', 'ezsearch_return_count', 'ezsearch_search_phrase', 'ezsearch_word'];
     foreach ($tables as $tbl) {
         $query->deleteFrom($tbl);
         $stmt = $query->prepare();
         $stmt->execute();
     }
     $this->dbHandler->commit();
 }
开发者ID:ezsystems,项目名称:ezpublish-kernel,代码行数:15,代码来源:SearchIndex.php

示例2: buildWordIDArray

 /**
  * Build WordIDArray and update ezsearch_word table.
  *
  * Ported from the legacy code
  *
  * @see https://github.com/ezsystems/ezpublish-legacy/blob/master/kernel/search/plugins/ezsearchengine/ezsearchengine.php#L155
  *
  * @param array $indexArrayOnlyWords words for object to add
  *
  * @return array wordIDArray
  */
 private function buildWordIDArray(array $indexArrayOnlyWords)
 {
     $wordCount = count($indexArrayOnlyWords);
     $wordIDArray = [];
     $wordArray = [];
     // store the words in the index and remember the ID
     $this->dbHandler->beginTransaction();
     for ($arrayCount = 0; $arrayCount < $wordCount; $arrayCount += 500) {
         // Fetch already indexed words from database
         $wordArrayChuck = array_slice($indexArrayOnlyWords, $arrayCount, 500);
         $wordRes = $this->searchIndex->getWords($wordArrayChuck);
         // Build a has of the existing words
         $wordResCount = count($wordRes);
         $existingWordArray = [];
         for ($i = 0; $i < $wordResCount; ++$i) {
             $wordIDArray[] = $wordRes[$i]['id'];
             $existingWordArray[] = $wordRes[$i]['word'];
             $wordArray[$wordRes[$i]['word']] = $wordRes[$i]['id'];
         }
         // Update the object count of existing words by one
         if (count($wordIDArray) > 0) {
             $this->searchIndex->incrementWordObjectCount($wordIDArray);
         }
         // Insert if there is any news words
         $newWordArray = array_diff($wordArrayChuck, $existingWordArray);
         if (count($newWordArray) > 0) {
             $this->searchIndex->addWords($newWordArray);
             $newWordRes = $this->searchIndex->getWords($newWordArray);
             $newWordCount = count($newWordRes);
             for ($i = 0; $i < $newWordCount; ++$i) {
                 $wordLowercase = $this->transformationProcessor->transformByGroup($newWordRes[$i]['word'], 'lowercase');
                 $wordArray[$wordLowercase] = $newWordRes[$i]['id'];
             }
         }
     }
     $this->dbHandler->commit();
     return $wordArray;
 }
开发者ID:ezsystems,项目名称:ezpublish-kernel,代码行数:49,代码来源:DoctrineDatabase.php

示例3: beginTransaction

 /**
  * Begin transaction.
  */
 public function beginTransaction()
 {
     $this->dbHandler->beginTransaction();
 }
开发者ID:ezsystems,项目名称:ezpublish-kernel,代码行数:7,代码来源:TransactionHandler.php


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