I have 2 tables Users and UserStatus, with models generated with phalcon tools, so the relationships hasMany/belongsTo are correct.
When I try to update the status of the user, there is no errors, and no change in the db.
$user = Users::findFirst(16); $user->user_status_id = 1; $user->save(); // or update()
I tried this post : https://forum.phalconphp.com/discussion/3210/not-update-foreignkey-value But no changes.
And I found this issue : https://github.com/phalcon/cphalcon/issues/1867 That is exactly my problem.
I have Phalcon 2.0.7, PHP 5.6. I know the issue is pending, but I want to know if you have a solution ?, because I tried all the answers in the post and nothing works for me...
By the way, after logging the SQL, this is the output (for the 3 lines above) :
UPDATE `users` SET `username` = ?, `email` = ?, `password` = ? WHERE `id` = ? AND `user_status_id` = ?
As you can see, the modified field is put in WHERE clause, and not in the fields to be modified. So as the row doesn't exists n the db, no change and no error (because the sql generated in right).
Thank you for your help or answers !