仅使用 MySQLi 获取一行

2021-12-25 00:00:00 php mysqli

如何使用 MySQLi 只获取一个 INDEXED 行?我目前正在这样做:

How can I only fetch one INDEXED row with MySQLi? I'm currently doing this:

$row = $result->fetch(MYSQLI_ASSOC);
$row = $row[0];

还有别的方法吗?

我知道 mysqli_fetch_row 但它不返回关联数组.

I'm aware of mysqli_fetch_row but it doesn't return an associative array.

推荐答案

使用 $row = $result->fetch_assoc(); - 与 fetch_row() 相同code> 但返回一个关联数组.

Use $row = $result->fetch_assoc(); - it's the same as fetch_row() but returns an associative array.

相关文章