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

Model save() do not work with Autocommit disabled

I use PDO::ATTR_AUTOCOMMIT => 0 in my bootstrap.

I'm trying to update a record. I'm doing something like this:

$thing = Thing::findFirst( $id );
$thing->someProperty = 'some another value';
$result = $thing->save();

When I try to save a model instance, it returns true, with no error messages in the $thing->getMessages(). If I enable Autocommit, it works well. But with autocommit disabled, it does not save, even if I add an implicit transaction.

Why doesn't this call return an error and how can I find out what is blocking transaction commit?

Hi,

I think you need use assign function for update

$thing = Thing::findFirst( $id ); $thing->assign(array( 'someProperty' => 'some another value' )); $result = $thing->save();