Hi all,
I'm just starting to work with Phalcon models/ORM and I'm encoutering a really weird issue (Phalcon 2.05). I have a user model, no relation with other models for now, and I just try to update a set of rows as a test. Problem: all my rows end up being updated with the same value (the last one in the loop).
Here is the code:
$aoUsers = $oUser::find(array('order' => 'id DESC'));
if(!$aoUsers)
{
dump('Error');
}
else
{
// Traversing with a while
$aoUsers->rewind();
while ($aoUsers->valid())
{
$oUser = $aoUsers->current();
dump('update 1 user Model');
$sEmail = 'updatedEmail'.rand(9999,9999999).'@email.com';
dump($sEmail);
$oUser->email = $sEmail;
if(!$oUser->save())
{
dump('error saving user');
dump($oUser->getMessages());
}
$aoUsers->next();
}
}
Am I doing something wrong ? Or is there a really weird thing going on in the model ? Cheers