2
看看是否有简单的方法从函数中的数据库查询中倾出我的结果。从函数返回数据库数组
功能:
function getAllCustomers() {
global $mysqli;
$query = $mysqli->query("SELECT * FROM customers");
return $query;
}
这是一类,所以:
$customer = new Customer();
print_r($customer->getAllCustomers());
这说明:
mysqli_result Object ([current_field] => 0 [field_count] => 10 [lengths] => [num_rows] => 24 [type] => 0)
但我希望返回所有的数组所有行的字段和值。
我知道我可以运行一个foreach,但不知道是否有一个更简单的方法?
为['mysqli_result'(http://php.net/manual/en/class.mysqli-result.php),其显然你是从函数返回的,你应该能够自己回答这个问题。 – Jon 2015-02-06 15:01:42