Php Errors Yii Relations

Hi,

I am often faced with this problem when doing Yii relations.

If I string together a set of relations like …

$book->author->address->Town;

If one of those relations is not connected PHP will generate a message saying …

Trying to get property of a non object.

So I am left with doing something like this …

is_object($book->author) && is_object($book->author->address) // do something etc.

Is there an easier way to test the validity of the relation string without having to test every single object like that?

Seems that isset() seems to do what is needed. It can handle method property chains.