开发者

Yii code issue: Works on local machine fails on server

I have been encountering some strange behaviour with some bits of my yii code.Let me pick out one in particular.

The code

$model = new Socialdemo;
$model = $model->findByAttributes(array('fk_recordid'=>$record_id));

$new = new Socialdemo();
$data = $model->attributes;
$data['fk_recordid'] = $new_recordid;
unset($data['id']); //unset id since we want to insert
$new->setAttributes($data, false);
$new->save();

On my local development machine is works just fine but when I deploy it on the server if brings up an error on the line of code

$data = $model->attributes;

It brings out the php error

Trying to get propert开发者_运维百科y of non-object

What am I missing?


Do you have the same Db data on server? have you checked on NULL value?

$model = $model->findByAttributes(array('fk_recordid'=>$record_id));


Why are you missing the brackets after the new declaration

$model = new Socialdemo();

Also, I assume you are including a file to the Socialdemo class, is the file copied to the correct location and path correct on the server?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜