Yii Framework Forum: Getting Blank Page With A Model Relation When Adding More To "on" - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Getting Blank Page With A Model Relation When Adding More To "on" Rate Topic: -----

#1 User is offline   atrandafir 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 17
  • Joined: 08-April 09
  • Location:Sabadell, Spain

Posted 05 December 2012 - 04:57 AM

Hello,

I have this relation:

'image'=>array(self::HAS_ONE, 'Image', array('content_id' => 'id_place'), 'condition'=>"image.content_type='place' AND image.cover=1"),


That works but when I do a find with('image') it will only show me results that DO have the image relations, the ones missing it will not appear because of the condition.

So I tried to change it to ON instead of condition, like this:

'image'=>array(self::HAS_ONE, 'Image', array('content_id' => 'id_place'), 'on'=>"image.content_type='place' AND image.cover=1"),


But with this configuration it just gives me a blank page with no errors.

Am I doing it right?
0

#2 User is offline   atrandafir 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 17
  • Joined: 08-April 09
  • Location:Sabadell, Spain

Posted 05 December 2012 - 05:02 AM

I am updating it:

The relation does work, but I forgot to check if $model->image was NULL before calling it, so that what was giving me the blank screen. The items that did not have the image relation were giving the error because I did not check it before calling it.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users