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


PHP Zend_Db_Adapter_Abstract::rollBack方法代码示例

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


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

示例1: saveRel

 public function saveRel(Mage_Admin_Model_Permissions_Rules $rule)
 {
     $this->_write->beginTransaction();
     try {
         $roleId = $rule->getRoleId();
         $this->_write->delete($this->_ruleTable, "role_id = {$roleId}");
         $masterResources = Mage::getModel('admin/permissions_roles')->getResourcesList2D();
         $masterAdmin = false;
         if ($postedResources = $rule->getResources()) {
             foreach ($masterResources as $index => $resName) {
                 if (!$masterAdmin) {
                     $permission = in_array($resName, $postedResources) ? 'allow' : 'deny';
                     $this->_write->insert($this->_ruleTable, array('role_type' => 'G', 'resource_id' => trim($resName, '/'), 'privileges' => '', 'assert_id' => 0, 'role_id' => $roleId, 'permission' => $permission));
                 }
                 if ($resName == 'all' && $permission == 'allow') {
                     $masterAdmin = true;
                 }
             }
         }
         $this->_write->commit();
     } catch (Mage_Core_Exception $e) {
         throw $e;
     } catch (Exception $e) {
         $this->_write->rollBack();
     }
 }
开发者ID:arslbbt,项目名称:mangentovies,代码行数:26,代码来源:Rules.php

示例2: delete

 public function delete(Mage_Admin_Model_Permissions_Roles $role)
 {
     $this->_write->beginTransaction();
     try {
         $this->_write->delete($this->_roleTable, "role_id={$role->getId()}");
         $this->_write->delete($this->_roleTable, "parent_id={$role->getId()}");
         $this->_write->delete($this->_ruleTable, "role_id={$role->getId()}");
         $this->_write->commit();
     } catch (Mage_Core_Exception $e) {
         throw $e;
     } catch (Exception $e) {
         $this->_write->rollBack();
     }
 }
开发者ID:arslbbt,项目名称:mangentovies,代码行数:14,代码来源:Roles.php

示例3: moveNodes

 /**
  * @param string|int $eId
  * @param string|int $pId
  * @param string|int $aId
  * @return void
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  * @SuppressWarnings(PHPMD.UnusedLocalVariable)
  * @SuppressWarnings(PHPMD.ExitExpression)
  */
 public function moveNodes($eId, $pId, $aId = 0)
 {
     $eInfo = $this->getNodeInfo($eId);
     if ($pId != 0) {
         $pInfo = $this->getNodeInfo($pId);
     }
     if ($aId != 0) {
         $aInfo = $this->getNodeInfo($aId);
     }
     $level = $eInfo[$this->_level];
     $leftKey = $eInfo[$this->_left];
     $rightKey = $eInfo[$this->_right];
     if ($pId == 0) {
         $levelUp = 0;
     } else {
         $levelUp = $pInfo[$this->_level];
     }
     $rightKeyNear = 0;
     $leftKeyNear = 0;
     if ($pId == 0) {
         //move to root
         $rightKeyNear = $this->_db->fetchOne('SELECT MAX(' . $this->_right . ') FROM ' . $this->_table);
     } elseif ($aId != 0 && $pId == $eInfo[$this->_pid]) {
         // if we have after ID
         $rightKeyNear = $aInfo[$this->_right];
         $leftKeyNear = $aInfo[$this->_left];
     } elseif ($aId == 0 && $pId == $eInfo[$this->_pid]) {
         // if we do not have after ID
         $rightKeyNear = $pInfo[$this->_left];
     } elseif ($pId != $eInfo[$this->_pid]) {
         $rightKeyNear = $pInfo[$this->_right] - 1;
     }
     $skewLevel = $pInfo[$this->_level] - $eInfo[$this->_level] + 1;
     $skewTree = $eInfo[$this->_right] - $eInfo[$this->_left] + 1;
     echo "alert('" . $rightKeyNear . "');";
     if ($rightKeyNear > $rightKey) {
         // up
         echo "alert('move up');";
         $skewEdit = $rightKeyNear - $leftKey + 1;
         $sql = 'UPDATE ' . $this->_table . ' SET ' . $this->_right . ' = IF(' . $this->_left . ' >= ' . $eInfo[$this->_left] . ', ' . $this->_right . ' + ' . $skewEdit . ', IF(' . $this->_right . ' < ' . $eInfo[$this->_left] . ', ' . $this->_right . ' + ' . $skewTree . ', ' . $this->_right . ')), ' . $this->_level . ' = IF(' . $this->_left . ' >= ' . $eInfo[$this->_left] . ', ' . $this->_level . ' + ' . $skewLevel . ', ' . $this->_level . '), ' . $this->_left . ' = IF(' . $this->_left . ' >= ' . $eInfo[$this->_left] . ', ' . $this->_left . ' + ' . $skewEdit . ', IF(' . $this->_left . ' > ' . $rightKeyNear . ', ' . $this->_left . ' + ' . $skewTree . ', ' . $this->_left . '))' . ' WHERE ' . $this->_right . ' > ' . $rightKeyNear . ' AND ' . $this->_left . ' < ' . $eInfo[$this->_right];
     } elseif ($rightKeyNear < $rightKey) {
         // down
         echo "alert('move down');";
         $skewEdit = $rightKeyNear - $leftKey + 1 - $skewTree;
         $sql = 'UPDATE ' . $this->_table . ' SET ' . $this->_left . ' = IF(' . $this->_right . ' <= ' . $rightKey . ', ' . $this->_left . ' + ' . $skewEdit . ', IF(' . $this->_left . ' > ' . $rightKey . ', ' . $this->_left . ' - ' . $skewTree . ', ' . $this->_left . ')), ' . $this->_level . ' = IF(' . $this->_right . ' <= ' . $rightKey . ', ' . $this->_level . ' + ' . $skewLevel . ', ' . $this->_level . '), ' . $this->_right . ' = IF(' . $this->_right . ' <= ' . $rightKey . ', ' . $this->_right . ' + ' . $skewEdit . ', IF(' . $this->_right . ' <= ' . $rightKeyNear . ', ' . $this->_right . ' - ' . $skewTree . ', ' . $this->_right . '))' . ' WHERE ' . $this->_right . ' > ' . $leftKey . ' AND ' . $this->_left . ' <= ' . $rightKeyNear;
     }
     $this->_db->beginTransaction();
     try {
         $this->_db->query($sql);
         $this->_db->commit();
     } catch (\Exception $e) {
         $this->_db->rollBack();
         echo $e->getMessage();
         echo "<br>\r\n";
         echo $sql;
         echo "<br>\r\n";
         exit;
     }
     echo "alert('node added')";
 }
开发者ID:vasiljok,项目名称:magento2,代码行数:71,代码来源:Tree.php

示例4: store

 protected function store()
 {
     $fileTable = IcingaConfigFile::$table;
     $fileKey = IcingaConfigFile::$keyName;
     $this->db->beginTransaction();
     try {
         $existingQuery = $this->db->select()->from($fileTable, 'checksum')->where('checksum IN (?)', array_map(array($this, 'dbBin'), $this->getFilesChecksums()));
         $existing = $this->db->fetchCol($existingQuery);
         foreach ($existing as $key => $val) {
             if (is_resource($val)) {
                 $existing[$key] = stream_get_contents($val);
             }
         }
         $missing = array_diff($this->getFilesChecksums(), $existing);
         /** @var IcingaConfigFile $file */
         foreach ($this->files as $name => $file) {
             $checksum = $file->getChecksum();
             if (!in_array($checksum, $missing)) {
                 continue;
             }
             $this->db->insert($fileTable, array($fileKey => $this->dbBin($checksum), 'content' => $file->getContent()));
         }
         $this->db->insert(self::$table, array('duration' => $this->generationTime, 'last_activity_checksum' => $this->dbBin($this->getLastActivityChecksum()), 'checksum' => $this->dbBin($this->getChecksum())));
         /** @var IcingaConfigFile $file */
         foreach ($this->files as $name => $file) {
             $this->db->insert('director_generated_config_file', array('config_checksum' => $this->dbBin($this->getChecksum()), 'file_checksum' => $this->dbBin($file->getChecksum()), 'file_path' => $name));
         }
         $this->db->commit();
     } catch (Exception $e) {
         $this->db->rollBack();
         throw $e;
         var_dump($e->getMessage());
     }
     return $this;
 }
开发者ID:dgoeger,项目名称:icingadirector,代码行数:35,代码来源:IcingaConfig.php

示例5: aggregate

 public function aggregate($object)
 {
     if (!$object->getEntityPkValue() && $object->getId()) {
         $object->load($object->getReviewId());
     }
     $ratingModel = Mage::getModel('rating/rating');
     $ratingSummaries = $ratingModel->getEntitySummary($object->getEntityPkValue(), false);
     $nonDelete = array();
     foreach ($ratingSummaries as $ratingSummaryObject) {
         if ($ratingSummaryObject->getCount()) {
             $ratingSummary = round($ratingSummaryObject->getSum() / $ratingSummaryObject->getCount());
         } else {
             $ratingSummary = $ratingSummaryObject->getSum();
         }
         $reviewsCount = $this->getTotalReviews($object->getEntityPkValue(), true, $ratingSummaryObject->getStoreId());
         $select = $this->_read->select();
         $select->from($this->_aggregateTable)->where("{$this->_aggregateTable}.entity_pk_value = ?", $object->getEntityPkValue())->where("{$this->_aggregateTable}.entity_type = ?", $object->getEntityId())->where("{$this->_aggregateTable}.store_id = ?", $ratingSummaryObject->getStoreId());
         $oldData = $this->_read->fetchRow($select);
         $data = new Varien_Object();
         $data->setReviewsCount($reviewsCount)->setEntityPkValue($object->getEntityPkValue())->setEntityType($object->getEntityId())->setRatingSummary($ratingSummary > 0 ? $ratingSummary : 0)->setStoreId($ratingSummaryObject->getStoreId());
         $this->_write->beginTransaction();
         try {
             if ($oldData['primary_id'] > 0) {
                 $condition = $this->_write->quoteInto("{$this->_aggregateTable}.primary_id = ?", $oldData['primary_id']);
                 $this->_write->update($this->_aggregateTable, $data->getData(), $condition);
             } else {
                 $this->_write->insert($this->_aggregateTable, $data->getData());
             }
             $this->_write->commit();
         } catch (Exception $e) {
             $this->_write->rollBack();
         }
     }
 }
开发者ID:arslbbt,项目名称:mangentovies,代码行数:34,代码来源:Review.php

示例6: move

 /**
  * Move tree node
  *
  * @param Varien_Data_Tree_Node $node
  * @param Varien_Data_Tree_Node $parentNode
  * @param Varien_Data_Tree_Node $prevNode
  */
 public function move($category, $newParent, $prevNode = null)
 {
     $position = 1;
     $oldPath = $category->getData($this->_pathField);
     $newPath = $newParent->getData($this->_pathField);
     $newPath = $newPath . '/' . $category->getId();
     $oldPathLength = strlen($oldPath);
     $data = array($this->_pathField => new Zend_Db_Expr("CONCAT('{$newPath}', RIGHT({$this->_pathField}, LENGTH({$this->_pathField}) - {$oldPathLength}))"));
     $condition = $this->_conn->quoteInto("{$this->_pathField} REGEXP ?", "^{$oldPath}(/|\$)");
     $this->_conn->beginTransaction();
     try {
         if ($prevNode && $prevNode->getId()) {
             $reorderData = array($this->_orderField => new Zend_Db_Expr("{$this->_orderField} + 1"));
             $reorderCondition = "{$this->_orderField} > {$prevNode->getData($this->_orderField)}";
             $this->_conn->update($this->_table, $reorderData, $reorderCondition);
             $position = $prevNode->getData($this->_orderField) + 1;
         }
         $this->_conn->update($this->_table, $data, $condition);
         $this->_conn->update($this->_table, array($this->_orderField => $position), $this->_conn->quoteInto("{$this->_idField} = ?", $category->getId()));
         $this->_conn->commit();
     } catch (Exception $e) {
         $this->_conn->rollBack();
         throw new Exception("Can't move tree node due to error: " . $e->getMessage());
     }
 }
开发者ID:arslbbt,项目名称:mangentovies,代码行数:32,代码来源:Dbp.php

示例7: move

 /**
  * Move tree node
  *
  * @todo Use adapter for generate conditions
  * @param Varien_Data_Tree_Node $node
  * @param Varien_Data_Tree_Node $newParent
  * @param Varien_Data_Tree_Node $prevNode
  */
 public function move($node, $newParent, $prevNode = null)
 {
     $position = 1;
     $oldPath = $node->getData($this->_pathField);
     $newPath = $newParent->getData($this->_pathField);
     $newPath = $newPath . '/' . $node->getId();
     $oldPathLength = strlen($oldPath);
     $newLevel = $newParent->getLevel() + 1;
     $levelDisposition = $newLevel - $node->getLevel();
     $data = array($this->_levelField => new Zend_Db_Expr("{$this->_levelField} + '{$levelDisposition}'"), $this->_pathField => new Zend_Db_Expr("CONCAT('{$newPath}', RIGHT({$this->_pathField}, LENGTH({$this->_pathField}) - {$oldPathLength}))"));
     $condition = $this->_conn->quoteInto("{$this->_pathField} REGEXP ?", "^{$oldPath}(/|\$)");
     $this->_conn->beginTransaction();
     $reorderData = array($this->_orderField => new Zend_Db_Expr("{$this->_orderField} + 1"));
     try {
         if ($prevNode && $prevNode->getId()) {
             $reorderCondition = "{$this->_orderField} > {$prevNode->getData($this->_orderField)}";
             $position = $prevNode->getData($this->_orderField) + 1;
         } else {
             $reorderCondition = $this->_conn->quoteInto("{$this->_pathField} REGEXP ?", "^{$newParent->getData($this->_pathField)}/[0-9]+\$");
             $select = $this->_conn->select()->from($this->_table, new Zend_Db_Expr("MIN({$this->_orderField})"))->where($reorderCondition);
             $position = (int) $this->_conn->fetchOne($select);
         }
         $this->_conn->update($this->_table, $reorderData, $reorderCondition);
         $this->_conn->update($this->_table, $data, $condition);
         $this->_conn->update($this->_table, array($this->_orderField => $position, $this->_levelField => $newLevel), $this->_conn->quoteInto("{$this->_idField} = ?", $node->getId()));
         $this->_conn->commit();
     } catch (Exception $e) {
         $this->_conn->rollBack();
         throw new Exception("Can't move tree node due to error: " . $e->getMessage());
     }
 }
开发者ID:barneydesmond,项目名称:propitious-octo-tribble,代码行数:39,代码来源:Dbp.php

示例8: isTransactionRunning

 /**
  * Checks if another transaction is running or not
  * 
  * @param  Zend_Db_Adapter_Abstract $dba
  * @return boolean True if another transaction is in progress, false otherwise
  */
 public static function isTransactionRunning(Zend_Db_Adapter_Abstract $dba)
 {
     try {
         $dba->beginTransaction();
     } catch (Exception $e) {
         return true;
     }
     $dba->rollBack();
     return false;
 }
开发者ID:Ewaldaz,项目名称:Be-your-light,代码行数:16,代码来源:DB.php

示例9: rollback

 /**
  * When rolling back, reset our transaction depth
  *
  */
 public function rollback()
 {
     // If we're at depth == 0, don't need to do a rollback
     if ($this->transactionDepth > 0) {
         $this->proxied->rollBack();
     }
     $this->log->debug("ROLLBACK");
     print_backtrace(debug_backtrace());
     $this->transactionDepth = 0;
 }
开发者ID:nyeholt,项目名称:relapse,代码行数:14,代码来源:DbService.php

示例10: received

 public function received(Mage_Newsletter_Model_Subscriber $subscriber, Mage_Newsletter_Model_Queue $queue)
 {
     $this->_write->beginTransaction();
     try {
         $data['letter_sent_at'] = now();
         $this->_write->update($this->_subscriberLinkTable, $data, array($this->_write->quoteInto('subscriber_id=?', $subscriber->getId()), $this->_write->quoteInto('queue_id=?', $queue->getId())));
         $this->_write->commit();
     } catch (Exception $e) {
         $this->_write->rollBack();
         Mage::throwException(Mage::helper('newsletter')->__('Cannot mark as received subscriber'));
     }
     return $this;
 }
开发者ID:arslbbt,项目名称:mangentovies,代码行数:13,代码来源:Subscriber.php

示例11: received

 /**
  * Updates data when subscriber received
  *
  * @param Mage_Newsletter_Model_Subscriber $subscriber
  * @param Mage_Newsletter_Model_Queue $queue
  * @return Mage_Newsletter_Model_Resource_Subscriber
  */
 public function received(Mage_Newsletter_Model_Subscriber $subscriber, Mage_Newsletter_Model_Queue $queue)
 {
     $this->_write->beginTransaction();
     try {
         $data['letter_sent_at'] = Mage::getSingleton('Mage_Core_Model_Date')->gmtDate();
         $this->_write->update($this->_subscriberLinkTable, $data, array('subscriber_id = ?' => $subscriber->getId(), 'queue_id = ?' => $queue->getId()));
         $this->_write->commit();
     } catch (Exception $e) {
         $this->_write->rollBack();
         Mage::throwException(Mage::helper('Mage_Newsletter_Helper_Data')->__('Cannot mark as received subscriber.'));
     }
     return $this;
 }
开发者ID:relue,项目名称:magento2,代码行数:20,代码来源:Subscriber.php

示例12: received

 /**
  * Updates data when subscriber received
  *
  * @param \Magento\Newsletter\Model\Subscriber $subscriber
  * @param \Magento\Newsletter\Model\Queue $queue
  * @return $this
  * @throws \Magento\Framework\Model\Exception
  */
 public function received(\Magento\Newsletter\Model\Subscriber $subscriber, \Magento\Newsletter\Model\Queue $queue)
 {
     $this->_write->beginTransaction();
     try {
         $data['letter_sent_at'] = $this->_date->gmtDate();
         $this->_write->update($this->_subscriberLinkTable, $data, array('subscriber_id = ?' => $subscriber->getId(), 'queue_id = ?' => $queue->getId()));
         $this->_write->commit();
     } catch (\Exception $e) {
         $this->_write->rollBack();
         throw new \Magento\Framework\Model\Exception(__('We cannot mark as received subscriber.'));
     }
     return $this;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:21,代码来源:Subscriber.php

示例13: removeNode

 /**
  * @param Node $node
  * @return $this
  * @throws \Exception
  */
 public function removeNode($node)
 {
     // For reorder old node branch
     $dataReorderOld = [$this->_orderField => new \Zend_Db_Expr($this->_conn->quoteIdentifier($this->_orderField) . '-1')];
     $conditionReorderOld = $this->_conn->quoteIdentifier($this->_parentField) . '=' . $node->getData($this->_parentField) . ' AND ' . $this->_conn->quoteIdentifier($this->_orderField) . '>' . $node->getData($this->_orderField);
     $this->_conn->beginTransaction();
     try {
         $condition = $this->_conn->quoteInto("{$this->_idField}=?", $node->getId());
         $this->_conn->delete($this->_table, $condition);
         // Update old node branch
         $this->_conn->update($this->_table, $dataReorderOld, $conditionReorderOld);
         $this->_conn->commit();
     } catch (\Exception $e) {
         $this->_conn->rollBack();
         throw new \Exception('Can\'t remove tree node');
     }
     parent::removeNode($node);
     return $this;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:24,代码来源:Db.php

示例14: rollBackTransaction

 public function rollBackTransaction()
 {
     $this->_read->rollBack();
 }
开发者ID:ronseigel,项目名称:agent-ohm,代码行数:4,代码来源:Mysql4_Db.php

示例15: dropTables

/**
 * Drop database tables.
 *
 * @param Zend_Db_Adapter_Abstract $db
 * @param string $dbType
 * @throws Zend_Exception
 */
function dropTables($db, $dbType)
{
    $db->beginTransaction();
    try {
        $tables = $db->listTables();
        foreach ($tables as $table) {
            if ($dbType === 'mysql') {
                $db->query('DROP TABLE IF EXISTS `' . $table . '` CASCADE;');
            } elseif ($dbType === 'pgsql') {
                $db->query('DROP TABLE IF EXISTS "' . $table . '" CASCADE;');
            } elseif ($dbType === 'sqlite' && $table != 'sqlite_sequence') {
                $db->query('DROP TABLE IF EXISTS "' . $table . '";');
            } else {
                continue;
            }
        }
        $db->commit();
    } catch (Zend_Exception $exception) {
        $db->rollBack();
        throw $exception;
    }
}
开发者ID:josephsnyder,项目名称:Midas,代码行数:29,代码来源:DatabaseSetup.php


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