==已解决==
我从以下帖子中得到此查询:
How to get ID of the last updated row in MySQL?
我在phpMyAdmin上尝试过,看到了我想要但无法获取的结果。
$query = "SET @order_id := '', @order_token := '', @order_param := ''; UPDATE transaction set `ts_status` = 'completed', `ts_remarks` = '', `tsid` = (SELECT @order_id := tsid), `token` = (SELECT @order_token := token), `param` = (SELECT @order_param := param) WHERE `token` = '503cd5c095fa942dbdfe72b2f4302edf' LIMIT 1; SELECT @order_id as order_id, @order_token as order_token, @order_param as order_param";
if($result = $con->query($query)){
$row = $result->fetch_array();
} else {
echo 'no result';
}
返回'无结果'
请告知。
== SOLUTION ==
if (!$con->multi_query($query)) {
echo "Multi query failed: (" . $mysqli->errno . ") " . $mysqli->error;
}
do {
if ($res = $con->store_result()) {
$row = $res->fetch_all(MYSQLI_ASSOC);
$res->free();
}
} while ($con->more_results() && $con->next_result());
echo '<pre>';
print_r($row);
echo '</pre>';