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


PHP MDB2_Driver_Common::rollback方法代碼示例

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


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

示例1: rollback

 function rollback()
 {
     if ($this->hasTransactions) {
         $this->oDbh->rollback();
         return true;
     }
     return false;
 }
開發者ID:villos,項目名稱:tree_admin,代碼行數:8,代碼來源:Common.php

示例2: commit

    /**
     * Commits keywords indexed by this indexer to the database index table
     *
     * If this indexer was created with the <code>$new</code> parameter then
     * the index is cleared for this indexer's document type before new
     * keywords are inserted. Otherwise, the new keywords are simply appended
     * to the existing index.
     */
    public function commit()
    {
        try {
            $this->db->beginTransaction();
            if ($this->new) {
                $this->clear();
                $this->new = false;
            }
            $indexed_ids = $this->db->implodeArray($this->clear_document_ids, 'integer');
            $delete_sql = sprintf('delete from NateGoSearchIndex
				where document_id in (%s) and document_type = %s', $indexed_ids, $this->db->quote($this->document_type, 'integer'));
            $result = $this->db->exec($delete_sql);
            if (MDB2::isError($result)) {
                throw new NateGoSearchDBException($result);
            }
            $keyword = array_pop($this->keywords);
            while ($keyword !== null) {
                $sql = sprintf('insert into NateGoSearchIndex (
						document_id,
						document_type,
						field_id,
						word,
						weight,
						location
					) values (%s, %s, %s, %s, %s, %s)', $this->db->quote($keyword->getDocumentId(), 'integer'), $this->db->quote($keyword->getDocumentType(), 'integer'), $this->db->quote($keyword->getTermId(), 'integer'), $this->db->quote($keyword->getWord(), 'text'), $this->db->quote($keyword->getWeight(), 'integer'), $this->db->quote($keyword->getLocation(), 'integer'));
                $result = $this->db->exec($sql);
                if (MDB2::isError($result)) {
                    throw new NateGoSearchDBException($result);
                }
                unset($keyword);
                $keyword = array_pop($this->keywords);
            }
            $popular_keyword = array_pop($this->popular_keywords);
            while ($popular_keyword !== null) {
                // TODO: there must be a better way to handle dupe words...
                $sql = sprintf('select count(keyword) from NateGoSearchPopularKeywords
					where keyword = %s', $this->db->quote($popular_keyword, 'text'));
                $exists = $this->db->queryOne($sql);
                if (MDB2::isError($result)) {
                    throw new NateGoSearchDBException($result);
                }
                if (!$exists) {
                    $sql = sprintf('insert into NateGoSearchPopularKeywords
						(keyword) values (%s)', $this->db->quote($popular_keyword, 'text'));
                    $result = $this->db->exec($sql);
                    if (MDB2::isError($result)) {
                        throw new NateGoSearchDBException($result);
                    }
                }
                unset($popular_keyword);
                $popular_keyword = array_pop($this->popular_keywords);
            }
            $this->clear_document_ids = array();
            $this->db->commit();
        } catch (NateGoSearchDBException $e) {
            $this->db->rollback();
            throw $e;
        }
    }
開發者ID:GervaisdeM,項目名稱:nate-go-search,代碼行數:67,代碼來源:NateGoSearchIndexer.php


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