仅使用 MySQLi 获取一行 [英] Fetching one row only with MySQLi

查看:17
本文介绍了仅使用 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.

这篇关于仅使用 MySQLi 获取一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆