We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

setHydrateMode

$members->setHydrateMode(Resultset::HYDRATE_OBJECTS);
foreach ($members as $key => $member) {
        $members->name = 'vendor';
}

$this->view->setVar("members", $members);

But I can't get the name in the view of value phalcon, please advise, I don't know what is the cause of the browser or, I can't reply you, thank you for your answer for me has been repeatedly newbie question, my English is not very good, also please understanding



34.6k
Accepted
answer

$members is an inmutable object whose modifications are not kept in memory to reduce memory usage. However you can append every member to an array to force keep it in memory.

$members->setHydrateMode(Resultset::HYDRATE_OBJECTS);

$modified = array();
foreach ($members as $key => $member) {
        $members->name = 'vendor';
        $modified[] = $member;
}

$this->view->setVar("members", $modified);