CodeIgniter-MY_Model icon indicating copy to clipboard operation
CodeIgniter-MY_Model copied to clipboard

exclusive where

Open stefanKBL opened this issue 9 years ago • 2 comments

Hi, certainly miss understood. I just try to get POSTS with PROMOTION, so excluding POST without Promotion, as i do with a basic sql query (SELECT * FROM posts INNER JOIN promotions ON posts.id=promotions.postid WHERE promotion = 'active')

Having two tables with a one to one relation. $this->posts->with_promotions('where:promotion='active')->limit(10)->get_all();

MY_MODEL do 2 queries, first getting 10 posts and then get promotions and merge.

Sure I'm not in the right way to do this but i can't find how.

thanks

stefanKBL avatar Dec 16 '16 12:12 stefanKBL

i don't understand the issue...

avenirer avatar Dec 22 '16 14:12 avenirer

Sorry. i just want to exclude posts without promotion relation; Depending on promotion status or not, but with the method i always get posts, even when no promotion in the relation. ex. if i have 10 posts, but only 2 with promotion, result must have only two records objects, not Ten.

stefanKBL avatar Dec 28 '16 18:12 stefanKBL