使用 PHP/MySQL 有一段时间了,我想知道使用 mysql_fetch_object()
与mysql_fetch_assoc()
/mysql_fetch_array()
.
最佳答案
就性能而言,您使用什么并不重要。不同的是mysql_fetch_object返回object:
while ($row = mysql_fetch_object($result)) {
echo $row->user_id;
echo $row->fullname;
}
mysql_fetch_assoc() 返回关联数组:
while ($row = mysql_fetch_assoc($result)) {
echo $row["userid"];
echo $row["fullname"];
}
而 mysql_fetch_array() 返回数组:
while ($row = mysql_fetch_array($result)) {
echo $row[0];
echo $row[1] ;
}
关于php - Mysql导致PHP - 数组或对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/124240/