I would like to have a simple method that can return PHP Activerecord results as simple / associative arrays, not an array of ActiveRecord objects.
In Ruby, I believe this is possible, perhaps with the help of the .map() method. (I'm not a guy from Ruby ...)
What I want is a simple method call, for example toArray() in Zend_DB_Table, and not foreach or something like that, but I can not find it in docs .
In PHP ActiveRecord, getting the result is very simple:
$settings = SystemSettings::all();
But it returns something like this:
[0] => SystemSettings Object ( [errors] => [attributes:ActiveRecord\Model:private] => Array ( [param] => author [value] => Hawle ) [__dirty:ActiveRecord\Model:private] => Array ( ) [__readonly:ActiveRecord\Model:private] => [__relationships:ActiveRecord\Model:private] => Array ( ) [__new_record:ActiveRecord\Model:private] => ) [1] => SystemSettings Object ( [errors] => [attributes:ActiveRecord\Model:private] => Array ( [param] => base_url [value] => example.com ) [__dirty:ActiveRecord\Model:private] => Array ( ) [__readonly:ActiveRecord\Model:private] => [__relationships:ActiveRecord\Model:private] => Array ( ) [__new_record:ActiveRecord\Model:private] => )
Although in many cases this is really great, I would just like to have a simple array, for example:
Array ( [author] => Hawle [base_url] => example.com )
source share