I am doing a simple query and want to return an array. Based on the ORM tutorial that comes with the Kohana 3 tutorial, I thought I could do the following:
ORM::factory('user')->find_all()->as_array();
But this seems to give me an array of model objects (i.e. an array (User_Model1, User_Model2 ...
Looking at the source, I see that I can easily fix this by cracking the next patch.
modules/database/classes/kohana/database/result.php
@@ -94,7 +94,7 @@
foreach ($this as $row)
{
- $results[] = $row;
+ $results[] = $row->as_array();
Which seems to be more consistent with what the user manual says:
A powerful feature of ORM is the ORM :: as_array method, which returns the specified record as an array. If used with ORM :: find_all, an array of all records will be returned. A good example of when this is useful is a list of choices:
// ( id ) echo :: select ('user', ORM:: factory ('user') → find_all() → as_array ('id', 'username'));
, , , ?
, ?