- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
考虑以下:
/** (Cas_Template_Tree::DeleteNode)
* Deletes the given node from the tree, and all of it's children.
*
* @static
* @throws Exception
* @param Cas_Template_Node $node
* @return void
*/
public static function DeleteNode(Cas_Template_Node $node)
{
$table = new Cas_Table_Templates();
$adapter = $table->getAdapter();
$leftStr = $adapter->quoteIdentifier('Left');
$rightStr = $adapter->quoteIdentifier('Right');
try
{
$adapter->beginTransaction();
$row = $table->find($node->GetId())->current();
$dependantRowSelector = array(
"$leftStr >= ?" => $row->Left,
"$rightStr <= ?" => $row->Right
);
//Get the rows removed so that we can nuke the ACLs later.
$rowsToDelete = $table->fetchAll($dependantRowSelector)->toArray();
//Delete the rows.
$table->delete($dependantRowSelector);
//Delete access control lists on those rows.
foreach ($rowsToDelete as $rowToDelete)
{
Cas_Acl::CreateExisting($rowToDelete['Acl'])->Delete();
}
$left = (int)$row->Left;
$right = (int)$row->Right;
$difference = $right - $left + 1;
$table->update(array('Left' => new Zend_Db_Expr("$leftStr - $difference")),
array("$leftStr > ?" => $right));
$table->update(array('Right' => new Zend_Db_Expr("$rightStr - $difference")),
array("$rightStr > ?" => $right));
$adapter->commit();
}
catch (Exception $ex)
{
$adapter->rollBack();
throw $ex;
}
}
/** (Cas_Acl::Delete)
* Removes this ACL (and all of its dependent access control entries) from the database.
* @return void
*/
public function Delete()
{
$aclTable = new Cas_Table_AccessControlLists();
$aceTable = new Cas_Table_AccessControlEntries();
$adapter = Zend_Db_Table_Abstract::getDefaultAdapter();
$identifierName = $adapter->quoteIdentifier('Identifier');
$aclName = $adapter->quoteIdentifier('Acl');
try
{
$adapter->beginTransaction();
$aceTable->delete(array("$aclName = ?" => $this->GetId()));
$aclTable->delete(array("$identifierName = ?" => $this->GetId()));
}
catch (Exception $ex)
{
$adapter->rollBack();
throw $ex;
}
}
Cas_Acl::Delete()
,它还尝试在事务 block 内执行自身。理想情况下,Zend_Db 会足够聪明地识别这种情况,并且对于这个特定的调用忽略
Cas_Acl::Delete
中的开始事务和提交/回滚调用。 .
最佳答案
阿法克Zend_Db
无法识别嵌套事务。看代码。
public function beginTransaction()
{
$this->_connect();
$q = $this->_profiler->queryStart('begin', Zend_Db_Profiler::TRANSACTION);
$this->_beginTransaction();
$this->_profiler->queryEnd($q);
return $this;
}
_beginTransaction
依赖于 PDO 的
beginTransaction
.
Delete()
确定是否使用事务的方法,并使用
false
调用它
DeleteNode()
中的参数:
//RB called as Cas_Acl::CreateExisting($rowToDelete['Acl'])->Delete(false);
public function Delete($useTransaction = true)
{
$aclTable = new Cas_Table_AccessControlLists();
$aceTable = new Cas_Table_AccessControlEntries();
$adapter = Zend_Db_Table_Abstract::getDefaultAdapter();
$identifierName = $adapter->quoteIdentifier('Identifier');
$aclName = $adapter->quoteIdentifier('Acl');
try
{
if ($useTransaction === true) {
$adapter->beginTransaction();
}
$aceTable->delete(array("$aclName = ?" => $this->GetId()));
$aclTable->delete(array("$identifierName = ?" => $this->GetId()));
//BTW isn't commit() should be called here?
}
catch (Exception $ex)
{
if ($useTransaction === true) {
$adapter->rollBack();
}
throw $ex;
}
}
关于php - Zend_Db_Adapter::beginTransaction() 是否堆栈?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4929947/
考虑以下: /** (Cas_Template_Tree::DeleteNode) * Deletes the given node from the tree, and all of it's c
我遇到交易问题 $backendB = new BackendBanner();//BackendBanner and ImageBanner extends Zend_Db_Table_Abstra
我在我的项目中使用 Zend Framework。我需要插入多条记录,我发现 Zend_Db 比 my_sql 查询慢得惊人(好几次),这让我觉得我做错了什么。这里有两个例子。 Zend_Db_Ada
让我们考虑一个非常基本的表: CREATE TABLE test_warning (col_a INT NOT NULL, col_b INT NOT NULL) +-------+---------
这是我编写的一个 Zend_Application_Resource,用于在部署中进行更改时自动更新模式。 getOptions(); $version = (int)$options
我已经开始通过德语版《Zend Framework in Action》一书学习 Zend Framework。 就在它开始变得有趣的地方,我的 PHP 单元测试抛出了这个错误:“Zend_Db_Ad
我是一名优秀的程序员,十分优秀!