Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我只是慢慢地从 mysql 迁移到 mysqli,并尝试使用 mysqli 编写一个新网站。我正在尝试计算行数,并尝试将以下 mysql 查询转换为 mysqli,但我有点摸不着头脑,因为 mysqli 的处理方式似乎完全不同。
$result = $db->query("SELECT COUNT(*) FROM `table`"); $row = $result->fetch_row(); echo '#: ', $row[0];
我可能会以冗长的方式执行此操作,但我倾向于针对一般查询执行以下操作
$query = $mysqli->prepare("SELECT COUNT(*) FROM `table`"); $query->execute(); $query->bind_result($count); $query->fetch(); $query->close();
$count 现在持有你想要的值。