首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Mysql越级回档失败

问Mysql越级回档失败
EN

Stack Overflow用户
提问于 2012-10-05 22:08:55
回答 2查看 384关注 0票数 0

我创建joomla(2.5)与hikashop (eshop组件)组件,以自动导入客户。问题是我使用的JDatabase事务没有按预期工作(回滚不起作用)。方法processSingle处理每个客户,并返回它是否成功。此外,为了进行调试,还有一个参数可以知道哪个方法(步骤)失败。我已经写了另一个脚本,它使用了相同的回滚结构,它似乎可以工作,但这个脚本不行。我尝试过捕获DatabaseException,但没有例外。有部分代码无法回滚事务。

代码语言:javascript
复制
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();
        }
    }

有没有人有类似的问题?顺便说一下,我使用的是PHP/5.3.3-7。

EN

回答 2

Stack Overflow用户

发布于 2012-10-05 22:15:55

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

票数 0
EN

Stack Overflow用户

发布于 2012-10-05 22:16:15

检查您的mysql配置是否开启了自动提交模式。关闭它可能会有所帮助。点击此处了解更多信息http://dev.mysql.com/doc/refman/5.0/en/commit.html

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12748092

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档