Join statement not workin properly... - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: Join statement not workin properly... (/showthread.php?tid=40581) |
Join statement not workin properly... - El Forum - 04-12-2011 [eluser]Roy MJ[/eluser] Im trying for some days now to make this join statement work. But its not working properly as i want it to work. Here is the controller : Code: function index($pgoffset='') The model part is as follows : Code: function get_total($id) View is as follows : Code: <?php foreach($friends as $row){?> Now basically its displaying all contents from the table 'members'. The join statement and the conditions are not working.. Join statement not workin properly... - El Forum - 04-12-2011 [eluser]CroNiX[/eluser] I'm not sure why you are joining on your first function. You are only retrieving one value (count) from one table. Quote:Now basically its displaying all contents from the table ‘members’. The join statement and the conditions are not working..That's because that's all you are selecting...from one table, 'members'. Code: $this->db->select('members.id,members.screenname,members.photo,members.email'); Code: $this->db->select('members.id as members_id,members.screenname as members_screenname,members.photo as members_photo,members.email as members_email'); Code: $this->db->join('friends','friends.member_id','left'); should be something like Code: $this->db->join('members','friends.member_id = members.id','left'); Join statement not workin properly... - El Forum - 04-13-2011 [eluser]Roy MJ[/eluser] Yeah but the $id is being passed dynamically. So Code: $this->db->join('members','friends.member_id =', $id','left'); doesnt work since its $id, a variable right? |