CodeIgniter App getting data from the wrong mySQL table? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: CodeIgniter App getting data from the wrong mySQL table? (/showthread.php?tid=12121) |
CodeIgniter App getting data from the wrong mySQL table? - El Forum - 10-07-2008 [eluser]Dave Blencowe[/eluser] Hey, Recently I have been coding the Blog section to my personal site which is based on Codeigniter and have run across a problem. I have made a model for getting things like posts etc from the database and then have the controller use the model to get the appropriate results yet when I ask for data from one table for comments it returns another table altogether and I just can't see why. The section of the model Code: function get_blog($id, $limit = NULL) The section of the controller Code: function comments() These two views seem to have the the $get_blogs variable passed to them each time... Code: $this->load->view('blog/comments/main_view', $get_blog); I've attached the files in case they are any use and I thank you for any help you might be able to provide. Thanks, Dave CodeIgniter App getting data from the wrong mySQL table? - El Forum - 10-07-2008 [eluser]xwero[/eluser] And you get result form which other table? CodeIgniter App getting data from the wrong mySQL table? - El Forum - 10-07-2008 [eluser]Dave Blencowe[/eluser] content_blog instead of content_test CodeIgniter App getting data from the wrong mySQL table? - El Forum - 10-07-2008 [eluser]xwero[/eluser] And you are sure Code: $get_comments = $this->mdl_blog->get_comments($id, NULL); Code: $get_comments = $this->mdl_blog->get_blog($id, NULL); CodeIgniter App getting data from the wrong mySQL table? - El Forum - 10-07-2008 [eluser]Dave Blencowe[/eluser] Yeah I am sure, Have removed that extra NULL now as it was needed earlier before I edited the code a bit. Still having the same problem . If you want me to do something like post the whole project somewhere I could? CodeIgniter App getting data from the wrong mySQL table? - El Forum - 10-07-2008 [eluser]xwero[/eluser] You can try to debug it with $this->db->last_query() to see if the content_test sql statement actually runs CodeIgniter App getting data from the wrong mySQL table? - El Forum - 10-07-2008 [eluser]Dave Blencowe[/eluser] I'm just watching Stargate at the moment so I'll give that a try in about 20 minutes Thanks a lot dude, Dave CodeIgniter App getting data from the wrong mySQL table? - El Forum - 10-07-2008 [eluser]Dave Blencowe[/eluser] Yeah, the last query run is: Code: SELECT * FROM (`content_test`) WHERE `post_id` = '1' ORDER BY `id` desc CodeIgniter App getting data from the wrong mySQL table? - El Forum - 10-07-2008 [eluser]xwero[/eluser] So get_comments should contain that data? You can check by using print_r. CodeIgniter App getting data from the wrong mySQL table? - El Forum - 10-07-2008 [eluser]Dave Blencowe[/eluser] print_r($get_comments); gives me Array ( ) |