當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DatabaseHandler::commit方法代碼示例

本文整理匯總了PHP中eZ\Publish\Core\Persistence\Database\DatabaseHandler::commit方法的典型用法代碼示例。如果您正苦於以下問題:PHP DatabaseHandler::commit方法的具體用法?PHP DatabaseHandler::commit怎麽用?PHP DatabaseHandler::commit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在eZ\Publish\Core\Persistence\Database\DatabaseHandler的用法示例。


在下文中一共展示了DatabaseHandler::commit方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: commit

 /**
  * Commit transaction.
  *
  * Commit transaction, or throw exceptions if no transactions has been started.
  *
  * @throws \RuntimeException If no transaction has been started
  */
 public function commit()
 {
     try {
         $this->dbHandler->commit();
     } catch (Exception $e) {
         throw new RuntimeException($e->getMessage(), 0, $e);
     }
 }
開發者ID:ezsystems,項目名稱:ezpublish-kernel,代碼行數:15,代碼來源:TransactionHandler.php

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

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


注:本文中的eZ\Publish\Core\Persistence\Database\DatabaseHandler::commit方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。