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 $userid->save(array("userid"=>1,"name"=>"Peter"). it always return "Password is required", or set password is null if i check password is null

thanks, Best Regard



2.4k
edited Nov '14

You should do something like

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


1.7k

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)) ;



1.7k

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