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