[英]INNODB and mysql PDO driver lock in share mode
With INNODB you can add to your query LOCK IN SHARE MODE;
使用INNODB,您可以将查询添加到
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: 我当前在PHP中使用的PDO函数当前如下所示:
//$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? 是否有PDO驱动程序功能设置可将其设置为共享模式? 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?
还是应该将其简单地添加到查询字符串中?
You have to create your query to mach the MySQL syntax and that's all, for example: 您必须创建查询来实现MySQL语法,仅此而已,例如:
SELECT * FROM parent WHERE NAME = 'Jones' LOCK IN SHARE MODE
Just append the LOCK IN SHARE MODE to the query string. 只需将LOCK IN SHARE MODE附加到查询字符串即可。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.