{Solved} Combine 2 results into one. |
I have these two model functions.
The get_posts function effects the function total_posts_by_user PHP Code: public function get_posts() { PHP Code: public function total_posts_by_user($user_id, $reply_id, $post_id) { On my controller function I have used $this->db->last_query() for the total_posts_by_user($user_id, $reply_id, $post_id) And out puts like code below but MY Question: On the get_posts In stead of making the 2 admin show how could I combine the 2 in to one using something like group_by and then changing the total_post to 2. I have tried group by not to sure what missing. $this->db->group_by('p.reply_id'); and $this->db->group_by('p.user_id'); Code: SELECT * FROM `post` WHERE `post_id` = '1' AND `reply_id` = '0' AND `user_id` = '2' // Main post Image Controller PHP Code: <?php
There's only one rule - please don't tell anyone to go and read the manual. Sometimes the manual just SUCKS!
Hi,
You need to count the user_id with your group by PHP Code: public function get_posts() { A good decision is based on knowledge and not on numbers. - Plato
(09-29-2016, 12:35 AM)salain Wrote: Hi, I think that did the trick but will test it some more.
There's only one rule - please don't tell anyone to go and read the manual. Sometimes the manual just SUCKS!
|
Welcome Guest, Not a member yet? Register Sign In |