[英]Codeigniter getting the results from db
I wonder if the following codes do the same thing? 我想知道以下代码是否做同样的事情?
1 1个
if ($query->num_rows() == 1) {
$row= $query->row_array();
$path = $row['path'];
$photo = $row['photo'];
}
2 2
if ($query->num_rows() == 1) {
foreach ($query->result() as $row){
$path = $row->path;
$photo = $row->photo;
}
}
Yes. 是。 One gets the result as an object the other an associative array.
一个将结果作为对象,另一个作为关联数组。 Same result.
结果相同。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.