i working on patient chart table in which i have table charts (mysql) and using YII frameworm for developement. in chart table there are column id | chart_name | details | ....
in details column save value as array
json_encode
format. like allergydeatils
and many other information.
in array of allergies store multiple allergies identify with allergies id each.
sample code is here
$model = new PatientsAllergy;
$chart = MedicalCharts::model()->findByPk($chartid);
$chartDetails = json_decode($chart->details);
$chartDetails->allergies->$allergyId = array(
'allergy_id' => $model->id,
'allergen' => Allergies::model()->findByAttributes(array('code' => $model->allergen_id))->name,
'allergy_location' => $model->allergy_location,
'allergy_reaction' => $model->allergy_reaction,
'allergy_severity_code' => $model->allergy_severity_code,
'allergy_start_date' => $model->allergy_start_date,
'is_active' => (($model->is_active == 1) ? ("Active") : ("InActive")),
'comments' => $model->comments
);
in above code i store inforamation in $chartDetails->allergies->$allergyId
and then it store in database
`$chart->details = json_encode($chartDetails);
$chart->save();
but in above code $chartDetails->allergies->$allergyId = array( /// data/////)
this line give me
error
`Creating default object from empty value (path/protected/controllers/PatientsController.php:2761)`
on sever but on localhost it run nice no error.
please help.
thanking you !