I have been working with yii for some time. But I still not got relations in active records correctly. I am using the yii blog site which is in demo folder in yii download.
I want to access a field of comments table. But I still not succeeded.
error:
Error 500
Object of class User could not be converted to string
I know this may be very trivial question. But if any one can help on this I would highly appreciate it.
hello nuvan you are getting the error because when you accessing the
$post->author
it fetches the post’s author object( that is you have relations specifed on the post model) so whenever you
echo $post->author
you will get this error because you are trying to print the author object. so if you want to access author’s data such as author’s name etc you can use like this