Why Does My Query Not Work ? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Why Does My Query Not Work ? (/showthread.php?tid=58481) |
Why Does My Query Not Work ? - El Forum - 06-14-2013 [eluser]vincej[/eluser] Hi ! I have a real simple query: Code: function getChild(){ For some bizaar reason which I can not pin point I am only getting the first value out - the "uri", ID and Title are missing. Code: array However, if I remove URI from the select - I get ID ... the next one along. My gut feeling is that there is something wrong with the way I am formulating the result array. I have checked the CI guide - but can not see what I am doing wrong. The data is there in the DB and the query is good - but what am I doing wrong with the array - I want all three values ? Many Thanks ! Why Does My Query Not Work ? - El Forum - 06-14-2013 [eluser]Syllean[/eluser] You're not altering the results array, so why not return it directly? Code: if ($Q->num_rows() > 0) Alternatively, you will need to do your loop like this: Code: if ($Q->num_rows() > 0) edit: added a counter to prevent the $child array key from incrementing for each item. Why Does My Query Not Work ? - El Forum - 06-14-2013 [eluser]vincej[/eluser] You are a rock star ! Thank you ! Thank you ! I've been away from CI for 6 months and clearly I have forgotten more than I knew. Cheers ! Why Does My Query Not Work ? - El Forum - 06-15-2013 [eluser]Pert[/eluser] It's because select only takes 1 attribute: Code: $this->db->select('uri','id','title'); If you add second attribute to select method, it should be boolean, if set to false CI won't try to add quotes around your table and column names. |