我需要数据库表中的最后一个有效条目,这将是具有最大主键的行。所以使用 mysqli,我的查询是“SELECT MAX(id) FROM table LIMIT 1”。此查询返回正确的数字(使用 print_r()),但我不知道如何访问它。这是主要代码。注意 $this->link 指的是带有 mysqli 连接的类。
$q="select max(id) from stones limit 1";
$qed=$this->link->query($q) or die(mysqli_error());
if($qed){
$row=$qed->fetch_object();
print_r($row);
echo $lastid=$row;//here is the problem
}
有效行 print_r($row) 回显“stdClass Object ([max(id)] => 68)”