We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

Relational Models throwing PHP Notice Non-Object with actual results from Database

I have two databases on two different servers. One is a local server, the other is a remote server. The data resides on the remote server, and the models are on the local server. They are connected via the ConnectionService() method in the Model class. Both of the Models are accessing the schemas on the remote server

Now when I do

$id = 1;

$result = MyNameSpace\User::findFirst(['conditions'=>'id=?1','bind'=>[1=>$id]]);

I get my result as expected. However, I have a related model called UserAddress. It has a hasOne relation.

So when I use


and I ouput it on the view, I get the results as expected. However, in my log files I am recieveing a notice.

PHP Notice: Trying to get property of non-object in /var/www/example/app/views/example_dir/example.phtml

Any one have any ideas on why this would be triggering a PHP notice?



is, in the error message, no details about the specific line in the phtml file that thrown you this error ?

Otherwise, full relevant code of Model/controller/view files could be helpfull to get any help from the forum users.

edited Mar '17

Probably because it returns null. Just set alias and use alias.