Db::startTrans();
try{
// $judgment=Db::table('bd_threads')->alias('t')
// ->join(['bd_services_relationship'=>'s',''],"t.shop_id=s.shop_id and s.staff_id=$staff_id",'INNER')
// ->where( function ($query) {
/** @noinspection PhpUndefinedMethodInspection */
// $query->where('t.sales_id',0)->whereor('t.sales_id',null);
// })->lock(true)->where('t.id',input('param.thread_id'))->where('t.status',null )->count();
$sql= 'SELECT
COUNT(*) AS tp_count
FROM
`bd_threads` `t`
INNER JOIN `bd_services_relationship` `s` ON `t`.`shop_id` = s.shop_id
AND s.staff_id = ?
WHERE
(
`t`.`sales_id` = 0
OR `t`.`sales_id` IS NULL
)
AND `t`.`id` = ?
AND `t`.`status` IS NULL
LIMIT 1 FOR UPDATE';
$judgment=Db::query($sql,[$staff_id,input('thread_id')]);
if(!$judgment) return json_error('此线索不在我抢的范围或已经被抢!');
// dump($judgment);die();
$rs=db('threads','',false)->where(['id'=>input('param.thread_id')])->update($updata_data);
Db::commit();
} catch (\Exception $e) {
Db::rollback();
return json_error('抢单失败');
}返回提示:<b>Warning</b>: Uncaught PDOException: SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction in F:\PHPstudy\WWW\bd\thinkphp\library\think\db\Connection.php:431
Stack trace:
#0 F:\PHPstudy\WWW\bd\thinkphp\library\think\db\Connection.php(431): PDOStatement->execute()
#1 F:\PHPstudy\WWW\bd\thinkphp\library\think\db\Query.php(240): think\db\Connection->execute('UPDATE `bd_thre...', Array)
#2 F:\PHPstudy\WWW\bd\thinkphp\library\think\db\Query.php(2208): think\db\Query->execute('UPDATE `bd_thre...', Array)
#3 F:\PHPstudy\WWW\bd\application\api\controller\v1\Clue.php(273): think\db\Query->update(Array)
#4 [internal function]: app\api\controller\v1\Clue->snatching_thread()
#5 F:\PHPstudy\WWW\bd\thinkphp\library\think\App.php(224): ReflectionMethod->invokeArgs(ob
#6 F:\PHPstudy\WWW\bd\thinkphp\library\think\App.php(389): think\App::invokeMethod(Array, Array)
#7 F:\PHPstudy\WWW\bd\thinkphp\library\think\App.php(130): think\App::module(Array, Array, true)
#8 in <b>F:\PHPstudy\WWW\bd\thinkphp\library\think\db\Connection.php</b> on line <b>431</b><br />
<br />
<b>Fatal error</b>: Maximum execution time of 30 seconds exceeded in <b>F:\PHPstudy\WWW\bd\thinkphp\library\think\db\Connection.php</b> on line <b>431</b><br />
{"result":"fail","message":"Maximum execution time of 30 seconds exceeded"}
最佳答案