I’m trying to get an attribute from the ‘OrderItem’ table out of the result like this,
foreach($bookings as $booking)
{
echo $booking->price;
}
The “price” attribute is part of the OrderItem table. However, when I try to get the attribute like this it says… ‘Getting unknown property: common\models\ar\Booking::price’
How can I get an attribute from a foreign table in my booking model after the table join?
But doing it that way defeats the whole purpose of the table join in the first place. Instead of having to issue extra queries every time via the "lazy load" method we should be able to issue one query then reference the foreign attributes.
If I do it the way you suggested then there is no point in having the table join in the first place. It creates additional queries and unnecessary overhead if we use the "lazy load" method you suggest.