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

useDynamicUpdate(true); not working for partial update columns in MySql

My table has :

user_id name password

how can i update just "name" column via "save" function in models ?

i use "useDynamicUpdate" but it does not work.

i call $user_id->save(array("user_id"=>1,"name"=>"Peter"). it always return "Password is required", or set password is null if i check password is null

thanks, Best Regard



4.5k
edited Nov '14

You should do something like

    $users = Users::findFirst("user_id = '1'");
    $user->name = 'Peter';
    $user->save();


3.1k

It's not a good way. I have to select my DB one time before every update.

And if i want to update multiple rows with name = "Peter", i must use PHQL. It's not flexible.

Example : with Zend Framework , i just call $this->update(array("name" => "Peter"),array("user_id"=>1)) ;



3.1k

Yeap, it works perfect, but the performance is not good. it must select a database one or more times.