标题: 简单的数据库处理控制(controlling transaction)使用法
keenlio
新手上路
Rank: 1



UID 147
精华 0
积分 0
帖子 26
翻译 0
原创 0
阅读权限 10
注册 2007-7-3
来自 新加坡
状态 离线
发表于 2008-4-21 17:41  资料  主页 短消息  加为好友  添加 keenlio 为MSN好友 通过MSN和 keenlio 交谈
简单的数据库处理控制(controlling transaction)使用法

很多时候会同时有多个对database进行add,update,delete。有时难免出现错误而处理不当。ZF的controlling transaction很简单,如果出现错误,将不会对实行uery,而会rollback。
/** Controlling transaction **/
    $db->beginTransaction();
    try {
        $db->delete('detail', $where);
        $db->delete('tentry', $where);
        $db->update('header', $array, $where);
    $db->commit();
    }
    catch (Exception $e) {
      $db->rollBack();
      $errorMsg[] = "Error in update invoice transaction! Please contact administrator!";
    }// end of catch exception
    /** end of controlling transaction **/





不思量 自难忘
顶部
yhl_amerry
新手上路
Rank: 1



UID 1230
精华 0
积分 0
帖子 26
翻译 0
原创 0
阅读权限 10
注册 2008-5-26
状态 离线
发表于 2008-6-5 09:33  资料  短消息  加为好友 
顶..............

顶部
 


PHPEye开源社区


当前时区 GMT+8, 现在时间是 2008-9-7 07:02

    Powered by Discuz! 5.5.0  © 2001-2007 Comsenz Inc.
Processed in 0.012402 second(s), 6 queries , Gzip enabled

清除 Cookies - 联系我们 - PHPEye开源社区 - Archiver