Home  >  Article  >  Database  >  php-PHP怎么能判断加了for update查询的mysql语句是否锁表了,如果锁表延时2秒。请教各位

php-PHP怎么能判断加了for update查询的mysql语句是否锁表了,如果锁表延时2秒。请教各位

WBOY
WBOYOriginal
2016-06-06 09:43:231264browse

mysqlphpupdate

mysql加了mysql for update查询时,怎么判断锁表。 详细:最近在做一个项目(PHP),有条查询语句for update过,我想实现,当执行到该查询语句时,如果该查询语句此时有另外一个用户在执行,用sleep延时2秒再执行。我目前的思路是:该查询语句不是加了for update吗,那就判断如果该表锁表了,就延时2秒,是否可以判断是否锁表了,如果锁表了就延时2秒。请教各位大牛是否可以判断,怎么判断?或者有没有更好的其他解决方案,当查询到该语句锁表时延时2秒再执行? (我知道for update后是要等到解锁了再执行该语句。但是目前我的问题是想,当锁表了再延时2秒,来加大其中的时间差。所以我才想延时2秒。)

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn