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

[eluser]bluepicaso[/eluser]
ok here is a problem

the code works fine. But results are unexpected.

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

the result i get is this.

Though the record is different but displays same user details.
Pleas help me. Its due to some unlogical active record I'm calling.
please help


Quote:Array
(
[0] => Array
(
[frnd_id] => 8
[user_id] => 9
[frnd_is] => 15
[status] =>
[username] => bluepicaso
[email] => [email protected]
[pwd] => b68283b19320106c5a12efdc35a39e5c
[display_name] => misha
[about_me] => Hey all How r u?
[thumb] => uploads/user/99_thumb.jpg
[image] => uploads/user/99.jpg
[location] => Delhi
[cntry] => Brazil
[is_new] => 1
[cntry_id] => 32
[cntry_sm] => BR
)

[1] => Array
(
[frnd_id] => 11
[user_id] => 9
[frnd_is] => 17
[status] =>
[username] => bluepicaso
[email] => [email protected]
[pwd] => b68283b19320106c5a12efdc35a39e5c
[display_name] => misha
[about_me] => Hey all How r u?
[thumb] => uploads/user/99_thumb.jpg
[image] => uploads/user/99.jpg
[location] => Delhi
[cntry] => Angola
[is_new] => 1
[cntry_id] => 8
[cntry_sm] => AO
)

[2] => Array
(
[frnd_id] => 9
[user_id] => 9
[frnd_is] => 16
[status] =>
[username] => bluepicaso
[email] => [email protected]
[pwd] => b68283b19320106c5a12efdc35a39e5c
[display_name] => misha
[about_me] => Hey all How r u?
[thumb] => uploads/user/99_thumb.jpg
[image] => uploads/user/99.jpg
[location] => Delhi
[cntry] => Armenia
[is_new] => 1
[cntry_id] => 13
[cntry_sm] => AM
)

)

I want to show friends of user whome the user follows and the ones who follow this user.

Please help

i want to display each friends name but it displays current user in each record.


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