![]() |
model function generating weird query - 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: model function generating weird query (/showthread.php?tid=61085) |
model function generating weird query - El Forum - 09-14-2014 [eluser]Ignis Avis[/eluser] Following is the model function I use to get late fee from the database Code: function get_late_fee_by_id($id) { In my controller i am using following code to call it. Code: $data['late_info'] = $this->transaction_model->get_late_fee_by_id($this->uri->segment(3)); when passing to the view it generates following error Code: A PHP Error was encountered and in view this is the code Code: <?php foreach($late_info as $late) { ?> So i dumped the $data[late_info] which is null. so i wanted to see what query was executing. I found the query and ran it in mysql it generates perfect row which I inteded to generate. but for model function above, following query is generated. one extra parameter. I have no idea from where it is getting it. Code: SELECT `mwf_late_fee`, `total_due`, `grade` FROM (`mwf`, `student_info`) WHERE `1mwf_student_id` = 'MCS20145B53' AND `mwf_month` = 'September, 2014' AND `student_gen_id` = 'MCS20145B53' Its weird! to me. so rest of my controller function look like Code: public function generate_invoice() { So i'm kind of stuck. Please give me some guidelines. model function generating weird query - El Forum - 09-14-2014 [eluser]InsiteFX[/eluser] For one you are not getting the data with $this->db->get('table_name'); and two you need to return the query result back to your controller all of this is in your function get_late_fee_by_id($id) Read the CodeIgniter Users Guide on the Database and Active Record |