dongxun2903 2018-11-06 14:10
浏览 117

Sybase SQL Anywhere:使用CodeIgniter回滚事务

I'm running CodeIgniter 2 with SQL Anywhere (I have a custom class to handle connection with SAP DLLs).

I have a problem with a transaction containing many queries. One of them is raising an error (returned by a trigger while trying to update a table) : in that case, I want the transaction to be rollbacked at the end of the treatment, as you can see below.

$this->db->trans_start();
$this->db->query('AN SQL QUERY...');
$this->db->query('ANOTHER QUERY...'); //This raises an error
$this->db->trans_complete(); //A rollback is done, and should cancel the first query

I've tried to change following options :

  • chained => Off
  • continue_after_raiserror => On
  • on_tsql_error => Continue

What's weird is that I'm logging my queries : executing them manually in Interactive SQL works well ! It seems that the raised error breaks the transaction.

Could someone help me ?

Thanks

  • 写回答

1条回答 默认 最新

  • dongsu3138 2018-11-13 14:22
    关注

    Finally I find the solution : we just need to use some functions provided by SAP PHP's DLLs (http://dcx.sap.com/index.html#sa160/en/dbprogramming/php-support.html).

    • begin transaction with :

      sasql_set_option($this->conn_id, 'auto_commit', 0);

    • finally, if you need to commit :

      sasql_commit($conn_id);

    • and if you need to rollback :

      sasql_rollback($conn_id); sasql_set_option($conn_id, 'auto_commit', 1);

    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器