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


PHP MDB2_Driver_Common::beginTransaction方法代码示例

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


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

示例1: beginTransaction

 function beginTransaction()
 {
     if ($this->hasTransactions) {
         $result = $this->oDbh->beginTransaction();
         return !PEAR::isError($result);
     }
     return true;
 }
开发者ID:villos,项目名称:tree_admin,代码行数:8,代码来源:Common.php

示例2: beginTransaction

 /**
  * Start a transaction
  * @return bool
  */
 public static function beginTransaction()
 {
     self::connect();
     if (self::$backend == self::BACKEND_MDB2 && !self::$connection->supports('transactions')) {
         return false;
     }
     self::$connection->beginTransaction();
     self::$inTransaction = true;
     return true;
 }
开发者ID:ryanshoover,项目名称:core,代码行数:14,代码来源:db.php

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