I want to execute a multi query in PHP
MySQL
, and get the result. My queries are like this.
$sql1 = "set @uid:=(select chat_id from chat_notify where online=1 and engaged=0 limit 1);";
$sql1 .= "update chat_notify set engaged=1,emp_id=1 where chat_id=@uid;";
$sql1 .= " select @uid";
$sql = $mysqli->multi_query($sql1);
I want to get the result of the uid
in php
.
Change your code accordingly
$sql1 = "set @uid:=(select chat_id from chat_notify where online=1 and engaged=0 limit 1)";
$sql2 = "update chat_notify set engaged=1,emp_id=1 where chat_id=@uid";
$sql3 = "select @uid";
$mysqli->query($sql1);
$mysqli->query($sql2);
$res = $mysqli->query($sql3);
and then get your query result usual way
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.