public function getBloodDonorById($ID = null) { if ($ID == null) { return false; } $model = new BloodDonors(); $data = $model->findByPk($ID); if ($data) { return $data; } else { return false; } }
/** * Deletes a particular model. * If deletion is successful, the browser will be redirected to the 'admin' page. * @param integer $id the ID of the model to be deleted */ public function actionDelete($id) { if (Yii::app()->request->isPostRequest) { // we only allow deletion via POST request $model = new BloodDonors(); $response = $model->updateAll(array('satsang_centre_ref_id' => null), 'satsang_centre_ref_id=:x', array(':x' => $id)); $this->loadModel($id)->delete(); // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser if (!isset($_GET['ajax'])) { $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin')); } } else { throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.'); } }