Akelos Framework v1 forum archive. This forum is no longer maintained. To report bugs please visit https://github.com/akelos/akelos/issues
    • CommentAuthorhpatoio
     

    Hello.

    Is there already a function to get from an AkHasMany object an array with this structure

    array ( [0] => ( ['field1'] => ['value1'], ['field2'] => ['value2'], ['field3'] => ['value3], ['field4'] => ['value4']) [1] => ( ['field11'] => ['value11'], ['field22'] => ['value22'], ['field33'] => ['value33], ['field44'] => ['value44']) )

    Thanks

    -- Simone

    • CommentAuthorhpatoio
     

    Well, I couldn't way so here the function

    function toHash($object) { foreach ($object->_columns as $columnName => $columnDetails) { $row[$columnName] = $object->$columnName; } return $row; }

    Just call it this way :

    $myMatrix = array_map("toHash",$this->MyMaster->myChildren);

    Now I'm just wondering if something like this already exists in Akelos. Anybody ?

    -- Simone

    • CommentAuthorKaste
     

    ActiveRecord has ->select() and ->collect() which are a bit different.

    but

     ->select($myChildren,list_of_columns_to_select...);
    

    would be equivalent to what you did.