首页 > 学院 > 开发设计 > 正文

ECOS事务处理实例

2019-11-08 01:12:47
字体:
来源:转载
供稿:网友

       $objMdlaccount = app::get('sysuser')->model('account');

        $objMdlUser = app::get('sysuser')->model('user');

        $accountUser = $this->__PReAccountUser($data);

        $db = app::get('sysuser')->database();

        $db->beginTransaction();

        try

        {

            if( !$userId = $objMdlaccount->insert($accountUser) )

            {

                throw new /LogicException('会员数据保存错误');

            }

            $userData = $this->__preUser($userId, $data);

            if( !$objMdlUser->insert($userData) )

            {

                throw new /LogicException('会员数据保存错误');

            }

            $db->commit();

        }

        catch (Exception $e)

        {

            $db->rollback();

            throw $e;

        }

        return $userId;


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表