I'm using idiorm as an ORM library and the method as_array() doesn't work with multiple rows.
$p = $db->find_many()->as_array();
it gives me thi开发者_开发知识库s error
Fatal error: Call to a member function find_many() on a non-object in
According to the idiorm documentation:
Any method chain that ends in find_many() will return an array of ORM class instances, one for each row matched by your query. If no rows were found, an empty array will be returned.
So essentially you are trying to call a method on an array, which is not an object, and thus the fatal error. What you need to do if you want to have your rows as arrays, is to loop through each of the find_many()
array items and convert them to array with separate as_array()
calls. Or, use the http://lt.php.net/array_map function.
on a non-object
in this case means the $db
object hasn't been initialised. Check that you're properly initialising the variable with a call like $db = new ORM;
.
精彩评论