Can anyone explain me how phalcon working with resultset? When I walk throw resultset and change some items properties, and after that I walk throw again - all my changes lost.
What I doing wrong?
Sample code from controller:
public function testAction()
{
$content = "<h2>Test update resultset w/o saving data</h2>";
/** @var OrdersItems[] $items */
$items = OrdersItems::find("external_item_id = 'Test'");
$i = 1;
foreach ($items as $item) {
$content .= $item->name . ': supplier_id update from ' . $item->supplier_id . ' to ' . $i++ . "<br />";
$item->supplier_id = $i;
}
$content .= "<hr /><h2>Walk again throw items</h2>";
foreach ($items as $item) {
$content .= $item->name . ': supplier_id = ' . $item->supplier_id . "<br />";
}
return $this->response->setContent($content);
}
Result output:
Test update resultset w/o saving data
Autogenerated item 1: supplier_id update from 5 to 1
Autogenerated item 2: supplier_id update from 4 to 2
Autogenerated item 3: supplier_id update from 3 to 3
Autogenerated item 4: supplier_id update from 2 to 4
Autogenerated item 5: supplier_id update from 1 to 5
Walk again throw items
Autogenerated item 1: supplier_id = 5
Autogenerated item 2: supplier_id = 4
Autogenerated item 3: supplier_id = 3
Autogenerated item 4: supplier_id = 2
Autogenerated item 5: supplier_id = 1