Closed kaemu closed 10 years ago
This does not currently exist as the model that https://github.com/j4mie/idiorm/blob/master/idiorm.php#L2425 gets passed is of type ORM and not your ParcelModel therefore you cannot access any methods defined on ParcelModel, but you can access any of the public methods of ORM.
You would have to define a new method on the result set class in Idiorm that takes a callable
and runs it against each item. This is not something that would be merged into Idiorm.
I would just use a function that processes the result set:
class ParcelModel extends \Model {
public static function my_as_array($result_set) {
$a = $result_set->as_array();
$a['area'] = $a['width'] * $a['height']; // add computed data to my model
return $a;
}
}
$rs = $myView->data->parcels = Model::factory('ParcelModel')->find_result_set();
$my_array = ParcelModel::my_as_array($rs);
Thank you for your response
By using the return_result_sets option, I would have liked to do the following:
It gives an IdiormMethodMissingException, Method my_as_array() does not exist in class IdiormResultSet
Is there a way for IdiormResultSet to call as_my_array?