For example there are 3 tables:
- products
- product_images
- product_specs
And there are one-to-one relationships in models of this 3 tables.
By showing 50 products on page - it get more +2 extra queries inside cycle, so in total there are 150 rows and cool object:
$products = Products::find();
foreach ($products as $product)
{
$product->name;
$product->images->filename;
$product->specs->volume;
}
Or just create custom method in Products Model and JOIN all necessary tables:
$products = Products::getComplete();
foreach ($products as $product)
{
$product->name;
$product->imageFile;
$product->specVolume;
}
So, i'm wondering: is 1st practice is useful and don't make high load on MySQL daemon or slowing drastically php script execution time?