MY_Model jamierumbelow

Guys

I have been using this model in my project.But ,nowadays i m facing with performance noises due to repeated query by with method and of course the need to make and Inner Join with Where clause on related objects and how could i ever does that?

I have Profile ,Media,Product table related.
When i want to get all products with profile , media and details i use below code.And , its working except the with createsrepeated select statements.

$all_products = $this->with('medias')->with('profile')->get_all();

Now , i want all products their profile is verified.

select * from products 
inner join profile as p on p.id = product.profile_id
inner join media as m on m.product_id=p.product_id 
where profile.is_verfied='true';

How can i ever do this using my MY_MODEL way or with little modifications.


Source: php

Leave a Reply