Welcome Guest, Not a member yet? Register   Sign In
database modeling for a friend list
#17

[eluser]bluepicaso[/eluser]
I found the Solution

here is the code for the model

Code:
function getUserFrnds($user_id, $num, $offset)
        {
            $this->db->select('*');
            $this->db->from('frnds');
            $this->db->where('frnds.usr_id', $user_id);
            $this->db->join('user', 'frnds.frnd_is = user.user_id', 'left');
            $this->db->join('country', 'user.cntry = country.cntry_id');
            $this->db->limit($num, $offset);
            $this->db->orderby('user.display_name');
            $query = $this->db->get()->result_array();
            foreach($query as $row)
            {
                if($row['user_id'] != $user_id)
                {
                    $data[] = $row;
                }
            }
            
            $this->db->select('*');
            $this->db->from('frnds');
            $this->db->where('frnds.frnd_is', $user_id);
            $this->db->join('user', 'frnds.frnd_is = user.user_id', 'left');
            $this->db->join('country', 'user.cntry = country.cntry_id');
            $this->db->limit($num, $offset);
            $this->db->orderby('user.display_name');
            $query2 = $this->db->get()->result_array();
            foreach($query2 as $row)
            {
                if($row['user_id'] != $user_id)
                {
                    $data[] = $row;
                }
            }
            

            
            //echo "<pre>";
            //print_r($data);
            //echo "</pre>";
            return $data;
            $this->db->close();
        }

generated results as expected.

Thank you JAY


Messages In This Thread
database modeling for a friend list - by El Forum - 04-16-2009, 04:15 PM
database modeling for a friend list - by El Forum - 04-16-2009, 05:03 PM
database modeling for a friend list - by El Forum - 04-16-2009, 06:45 PM
database modeling for a friend list - by El Forum - 04-16-2009, 07:29 PM
database modeling for a friend list - by El Forum - 04-16-2009, 08:54 PM
database modeling for a friend list - by El Forum - 04-16-2009, 10:54 PM
database modeling for a friend list - by El Forum - 04-16-2009, 11:58 PM
database modeling for a friend list - by El Forum - 04-19-2009, 07:35 PM
database modeling for a friend list - by El Forum - 05-07-2010, 10:24 AM
database modeling for a friend list - by El Forum - 05-07-2010, 11:01 AM
database modeling for a friend list - by El Forum - 05-07-2010, 11:04 AM
database modeling for a friend list - by El Forum - 05-07-2010, 11:12 AM
database modeling for a friend list - by El Forum - 05-11-2010, 12:37 PM
database modeling for a friend list - by El Forum - 05-12-2010, 12:40 AM
database modeling for a friend list - by El Forum - 05-12-2010, 10:22 AM
database modeling for a friend list - by El Forum - 05-12-2010, 10:27 AM
database modeling for a friend list - by El Forum - 05-14-2010, 10:49 AM
database modeling for a friend list - by El Forum - 05-15-2010, 12:27 PM



Theme © iAndrew 2016 - Forum software by © MyBB