Category Archives: Yii Model

Yii Model Update

This tutorial will help you to get the information about yii update function. I added the source code to update one or multiple records using different update function in yii framework model. <?php $model=User::model()->updateByPk($ID,array(“status”=>’DECLINED’)); $model=User::model()->updateAll(array( ‘first_name’=>”$firstname”, ’email’=>”$email” ), “UserID=$id and status IS NULL ” ); $model=User::model()->updateAll(array( ‘status’ => 1), ‘UserID =’.$userid); ?>

Yii Model Delete

This tutorial will help you to delete the record from database table using model in yii framework. I added the code to delete one or more record using yii framework model. /** 1 **/ $model=User::model()->findByPk($id); if($model) $model->delete(); /** 2 **/ $model=User::model()->deleteAll(); /** 3 **/ $model=User::model()->deleteAll(array(“condition”=>”userid=’$id'”)); /** 4 **/ $mode=User::model()->deleteAll(“status=’A'”);