作者:负能量包子玻璃包各负磁场宣泄区 | 来源:互联网 | 2023-05-18 02:45
$mysqli = new mysqli("localhost","root","","mydatabase");
if ($result = $mysqli->prepare("SELECT MAX(`id`) AS `id` FROM `mytable` WHERE `row1`=? OR `row2`=?"))
{
$id = 2;
$result->bind_param("ii",$id,$id);
$result->execute();
$result->bind_result($max);
$result->close();
var_dump($max);
}
$mysqli->close();
Unfortunately this code always showing NULL, can u folk explain me how to reach a result?
不幸的是,这段代码一直都是空的,你能告诉我怎么去实现吗?
updated:
更新:
in console mode staff like this works great. field id
is int and incremental (as PRIMARY INDEX), other fields it's just a rows with a different int values, I cant change anything.
像这样的控制台模式工作人员非常出色。字段id是int和增量(作为主索引),其他字段只是具有不同int值的行,我不能更改任何东西。
updated:
更新:
Well, seems I found the solution:
看来我找到了解决方案:
$mysqli = new mysqli("localhost","root","","mydatabase");
if ($result = $mysqli->prepare("SELECT MAX(`id`) AS `id` FROM `mytable` WHERE `row1`=? OR `row2`=?"))
{
$id = 2;
$result->bind_param("ii",$id,$id);
$result->execute();
$obj = $result->get_result()->fetch_object();
$max = $obj->id;
$result->close();
var_dump($max);
}
$mysqli->close();
this is it.
这是它。
2 个解决方案