cakephp - CakePHP3 Collection each iterator not modifying items -


i'm trying add 'modeltype' property each item in collection. however, doesnt seem showing afterward:

$results->each(function($row, $index) use ($modeltype) {    $row['modeltype'] = $modeltype; });  debug($results->toarray()); //<---- modeltype isn't listed in of items 

figured out. in example code, $results generated query hydrate set false, returns arrays rather entities.

took out ->hydrate(false) , each loop modified collection expected.


Comments