public function createHeightWeight($timestamp, $height, $weight, $id) { $exist = BiographyStat::model()->findByAttributes(array('timestamp' => $timestamp)); if ($exist) { $exist->height = $height; $exist->weight = $weight; $exist->patient_id = $id; $exist->timestamp = $timestamp; $exist->last_updated = time(); if ($exist->save(FALSE)) { ResponseHelper::JsonReturnSuccess("", "Success"); } else { ResponseHelper::JsonReturnError("", "Server Error"); } } else { $model = new BiographyStat(); $model->height = $height; $model->weight = $weight; $model->patient_id = $id; $model->timestamp = $timestamp; $model->last_updated = time(); if ($model->save(FALSE)) { ResponseHelper::JsonReturnSuccess($model->id, "Success"); } else { ResponseHelper::JsonReturnError("", "Server Error"); } } }
public function actionGetHeightWeight() { $this->retVal = new stdClass(); $request = Yii::app()->request; if ($request->isPostRequest && isset($_POST)) { try { $id = StringHelper::filterString($request->getPost('patient_id')); $data = BiographyStat::model()->findAllByAttributes(array('patient_id' => $id)); $this->retVal->data = $data; } catch (exception $e) { $this->retVal->message = $e->getMessage(); } header('Content-type: application/json'); echo CJSON::encode($this->retVal); Yii::app()->end(); } }