0

I am creating joomla(2.5) with hikashop (eshop component) component to automatically import customers. Problem is that I am using JDatabase transactions which is not working as expected(rollback does not work). Method processSingle processes each customer and returns weather it suceeded or not. Also for debugging there is one more parameter to know which method(step) failed. I have written another script which uses identical rolling back structure and it seems to work, but this one doesn't. I have tried to catch DatabaseException but there is no exceptions. There is part of code which fails rolling back transaction.

foreach ($this->customerList as $customer) {
        // start tracking database entries
        $this->db->transactionStart();

        $oCustomer = new stdClass();
        $oCustomer->raw_data = $customer;
        // escaping from sql injection
        $oCustomer = $this->escapeObj($oCustomer);
        // here we process all items taking one and going through all steps
        $methodfailed = "";
        $success = $this->processSingle($oCustomer, $methodfailed);
        $processed++;
        if ($success) {
            $succeeded++;
            // if succeded save changes
            $this->db->transactionCommit();
        } else {
            $failed++;
            echo $this->error . "<br/>";
            echo "failed method:" . $methodfailed . "<br/>";
            // if failed rollback database entries
            $this->db->transactionRollback();
        }
    }

Anyone had similar problems? By the way I am using PHP/5.3.3-7.

4

2 回答 2

0

我不知道是什么transactionStart,但只有 InnoDB 表支持事务。我敢打赌你的数据库表是 MyISAM。

于 2012-10-05T14:15:54.623 回答
0

检查您的 mysql 配置是否打开了自动提交模式。将其关闭会有所帮助。在此处阅读更多信息http://dev.mysql.com/doc/refman/5.0/en/commit.html

您还应该检查您的表是否是 InnoDB。MyISAM 不支持事务。

于 2012-10-05T14:16:14.880 回答