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