RAR Question

Hi.  I'm using:

$profileList = profile::model()->with('bio','contact')->findAll($criteria);

to get an array of profile objects, along with their corresponding bio and contact info.  I confirm the information is there by using var_dump.  I can see information from all three tables… however… I'm not sure how to reference the elements!

In my view, I have $model->profile_id and and $model->email … which work fine (and they're coming from the profile table).  But I'm not sure how to reference something from the contact or bio table.

When I try $model->name_first … I get this message: Property "profile.name_first" is not defined.  That's true… because name_first is in the table/model profile_contact.  How do I refer to it in the view?

Thank you all.

Also … I tried setting:

$contact = $model->contact;

and then tried to echo $contact->name_first; … but I get the following error message:

Trying to get property of non-object

Alright - so I was doing it right…

$model->contact->name_first

… but my first $model didn't have name_first set.  How can I set it so that it will echo '' when nothing is found in the JOIN?

I think I have the same problem as you have. Have you found any solution yet?

No - I never found a solution.  I just made sure each of my profiles had a name set before trying to call it.

Maybe someone can help us?

Does anyone know how to echo '' in the event that $profile->$contact->$name_first isn't set?

contact belongs to profile and I am using model->with('contact','bio')->together()->findbyPK(id);

Unfortunately, no magic here. You have to check the existence of $profile->contact first.