Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php foreach中的Joomla sql事务_Php_Arrays_Joomla_Foreach - Fatal编程技术网

Php foreach中的Joomla sql事务

Php foreach中的Joomla sql事务,php,arrays,joomla,foreach,Php,Arrays,Joomla,Foreach,你觉得这段代码怎么样?我不想执行来自数组的所有查询 foreach($sql_array as $sql) { try { $this->_db->transactionStart(); $this->_db->setQuery((string)$sql)->execute(); $this->_db->transactionCommit(); } catch (Exception

你觉得这段代码怎么样?我不想执行来自数组的所有查询

foreach($sql_array as $sql) {
     try {

        $this->_db->transactionStart();
        $this->_db->setQuery((string)$sql)->execute();
        $this->_db->transactionCommit();

     } catch (Exception $e) {
        $this->_db->transactionRollback();
        JErrorPage::render($e);
     }
}

或者我应该移动
$this->_db->transactionStart()在每项声明之前
你是在征求意见而不是答案。这是一个针对特定问题的问答网站,如果你想让别人看看你的代码,那么你是在征求意见而不是答案。这是一个针对特定问题的问答网站,如果你想让别人看看你的代码。