本文整理汇总了PHP中MDB2_Driver_Common::commit方法的典型用法代码示例。如果您正苦于以下问题:PHP MDB2_Driver_Common::commit方法的具体用法?PHP MDB2_Driver_Common::commit怎么用?PHP MDB2_Driver_Common::commit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MDB2_Driver_Common
的用法示例。
在下文中一共展示了MDB2_Driver_Common::commit方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: commit
function commit()
{
if ($this->hasTransactions) {
$result = $this->oDbh->commit();
return !PEAR::isError($result);
}
return true;
}
示例2: commit
/**
* Commit the database changes done during a transaction that is in progress
* @return bool
*/
public static function commit()
{
self::connect();
if (!self::$inTransaction) {
return false;
}
self::$connection->commit();
self::$inTransaction = false;
return true;
}
示例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;
}
}