$ chartDetails-> allergies-> $ allergyId = $ allergyTem此代码在localhost上运行很好但在服务器上出错

时间:2014-04-04 07:19:43

标签: php mysql yii

我在患者图表上工作,其中我有表格图表(mysql)和使用YII frameworm进行开发。在图表表中有列id | chart_name |细节| ....

在详细列中将值保存为array json_encode格式。喜欢allergydeatils

以及许多其他信息。

在一系列过敏症中存储多种过敏症,每种过敏症都会识别出来。

示例代码在这里

$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
                );

在上面的代码中我将信息存储在$chartDetails->allergies->$allergyId中,然后存储在数据库中

`$chart->details = json_encode($chartDetails);    
    $chart->save();

但在上面的代码$chartDetails->allergies->$allergyId = array( /// data/////)

中 这条线给了我
错误

`Creating default object from empty value     (path/protected/controllers/PatientsController.php:2761)`

在服务器上,但在localhost上它运行良好没有错误。

请帮忙。

感谢你!

0 个答案:

没有答案