dongye6377 2013-02-06 10: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 13: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.

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

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?