dongye6377 2013-02-06 02:06
浏览 55
已采纳

INNODB和mysql PDO驱动程序在共享模式下锁定

With INNODB you can add to your query LOCK IN SHARE MODE; so that other users can still read but not update untill the user that is editing is finished.

My current PDO function in PHP currently looks like:

//$this->db is a PDO connection to the MYSQL innodb database.
try 
    {
    $this->db->beginTransaction();
    $tmp = $this->db->prepare($query);  

    $tmp->execute($arr);
    $this->last_id = $this->db->lastInsertId();
    $this->db->commit();
    return $this->last_id;
    }
catch(PDOException $ex)
    {
    $this->db->rollBack();
    return $ex->getMessage();
    }

Is there an PDO driver function setting to set it in share mode? if so how? The only things I find have no answers to them and the documentation isn't really clear either. Or should I add it simply to the query string?

  • 写回答

1条回答 默认 最新

  • dongliang2058 2013-02-08 05:59
    关注

    You have to create your query to mach the MySQL syntax and that's all, for example:

    SELECT * FROM parent WHERE NAME = 'Jones' LOCK IN SHARE MODE
    

    Just append the LOCK IN SHARE MODE to the query string.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部