'PDOException',消息'没有活动的交易'

时间:2014-07-08 07:16:34

标签: zend-framework pdo transactions zend-db

try{
    $zenddb->beginTransaction();
    $result = $zenddb->query($selectmembergroupdetail);

    $memberDetail = $result->fetchAll();
    if (count($memberDetail) <= 0) {
        throw new Exception('NO user found.');
    }
    /* calculation code here */


    $result = $zenddb->query($selectadmingroupdetail);
    /* calculation code here */

    $zenddb->insert('orders', $insertorder['orders']);
    $order_id = $zenddb->lastInsertId();

    foreach ($insertorderproduct as $insertorder_product) {
        $insertorder_product['orders_id'] = $order_id;
        $zenddb->insert('orders_products', $insertorder_product);
    }
    $zenddb->commit();
}catch(Exception $e){
    $zenddb->rollBack();
}

我已将此代码用于数据库中的插入顺序。这主要是下订单功能。对于$ zenddb,我使用了

$params = array(
  'host' => DB_SERVER,  
  'username' => DB_USERNAME,  
  'password' => DB_PASSWORD,  
  'dbname' => DB_DATABASE,  
  //'charset' => 'utf-8'
);
$zendb = Zend_Db::factory('Pdo_Mysql', $params);

当我执行代码时,我得到了以下错误。

<br />
<b>Fatal error</b>:  Uncaught exception 'PDOException' with message 'There is no active transaction' in /opt/lampp/htdocs/myfeedly/library/Zend/Db/Adapter/Pdo/Abstract.php:322
Stack trace:
#0 /opt/lampp/htdocs/myfeedly/library/Zend/Db/Adapter/Pdo/Abstract.php(322): PDO-&gt;rollBack()
#1 /opt/lampp/htdocs/myfeedly/library/Zend/Db/Adapter/Abstract.php(524): Zend_Db_Adapter_Pdo_Abstract-&gt;_rollBack()
#2 /opt/lampp/htdocs/myfeedly/public/web_service/webservice/orders.php(201): Zend_Db_Adapter_Abstract-&gt;rollBack()
#3 /opt/lampp/htdocs/myfeedly/public/web_service/client.php(58): WebService-&gt;placeOrder(Array)
#4 {main}
  thrown in <b>/opt/lampp/htdocs/myfeedly/library/Zend/Db/Adapter/Pdo/Abstract.php</b> on line <b>322</b><br />

有人能指出我做错了吗? 在此先感谢:)

0 个答案:

没有答案