Tag Archives: Yii Update

Yii createCommand Update

Functions function update($table, $columns, $conditions=”, $params=array()) Sample The update() method builds and executes an UPDATE SQL statement. <?php $user=Yii::app()->db->createCommand() ->update(‘tbl_user’, array( ‘username’=>’bsourcecode’, ), ‘user_id=:id’, array(‘:id’=>1)); ?> OUTPUT SQL UPDATE `tbl_user` SET `username`=:username WHERE user_id=:id

Yii Framework 2 : Update Query

save() OR update() Update Multiple Records update() command Update By Sql Query You can use different type of methods to update the database records in yii2.0 framework. You can use model methods, execute() etc. save() OR update() Using model methods, You can load existing record and update the necessary changes in that. $model = User::find($id); […]

Yii Framework 2 : Upsert Query

Upsert is an atomic operation. `Upsert()` will insert new record into a database table If table do not already exist or update them. upsert( $table, $insertColumns, $updateColumns = true, $params = []) Using QueryBuilder $sql = $queryBuilder->upsert(‘pages’, [ ‘name’ => ‘Home page’, ‘url’ => ‘https://bsourcecode.com/’, // url is unique ‘visits’ => 10000, ], [ ‘visits’ […]