davykiash
davykiash

Reputation: 1804

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 property of non-object

What am I missing?

Upvotes: 0

Views: 239

Answers (2)

MattP
MattP

Reputation: 2863

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?

Upvotes: 0

Yuriy Vikulov
Yuriy Vikulov

Reputation: 2499

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

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

Upvotes: 1

Related Questions