php 仅使用 MySQLi 获取一行
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8893572/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Fetching one row only with MySQLi
提问by oaziz
How can I only fetch one INDEXED row with MySQLi? I'm currently doing this:
如何使用 MySQLi 只获取一个 INDEXED 行?我目前正在这样做:
$row = $result->fetch(MYSQLI_ASSOC);
$row = $row[0];
Is there another way?
还有其他方法吗?
I'm aware of mysqli_fetch_row but it doesn't return an associative array.
我知道 mysqli_fetch_row 但它不返回关联数组。
回答by You Qi
Use $row = $result->fetch_assoc();
- it's the same as fetch_row()
but returns an associative array.
使用$row = $result->fetch_assoc();
- 它与fetch_row()
但返回关联数组相同。