public function actionDelete_video($mid) { $videos = new Videos(); if ($to_delete = $videos->find('user_id = :my_id AND id = :video_id', array(':my_id' => Yii::app()->user->id, ':video_id' => $mid))) { $to_delete->delete(); } echo json_encode(array('status' => 'ok', 'count' => $count = $videos->count('user_id = :user_id', array('user_id' => Yii::app()->user->id)))); }