Yii update query builder
Yii update query builder : Yii::app()->db->createCommand()->update(tableName,data,condition) is used to update data in yii.
Yii update query builder Syntax with Example
You can update table data as below :
$data = array( "name" => "John", "email" => "john@example.com" ); $update = Yii::app()->db->createCommand() ->update('users', $data, 'id=:id', array(':id'=>$id) );
Where $id is primary key in user table and $data is associative array containing the column name and values.
Which will produce the following output :
UPDATE users set name = “John” AND email = “john@example.com” where id = “$id”
Advertisements