![]() |
Values in a function getting Nullified when calling SQL insert query - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Values in a function getting Nullified when calling SQL insert query (/showthread.php?tid=72895) |
Values in a function getting Nullified when calling SQL insert query - vinugenie - 02-26-2019 Hi Team i am running into a weird problem. I have created a function to insert some data into the database. i am getting the values to be inserted from Angular. unless the insert or query function is called ($this->db->insert('table_name', $data_array), i can see all the values coming to the function correctly and i can also print those values but as soon as i call the insert / query function and i run the code, the values are showing NULL or 0. Could somebody please help me on this issue. Code: public function course_landing_page_data($courseTitle, $courseSubTitle, $ins_id) { appreciate your help RE: Values in a function getting Nullified when calling SQL insert query - php_rocs - 02-26-2019 @vinugenie, You should use query binding ( https://www.codeigniter.com/user_guide/database/queries.html?highlight=query%20binding#query-bindings ) and batch inserts [$this->db->insert_batch()]( https://www.codeigniter.com/user_guide/database/query_builder.html?highlight=batch%20query#inserting-data ). If you use these features then CI will automatically escape all values for you. RE: Values in a function getting Nullified when calling SQL insert query - php_rocs - 02-26-2019 PHP Code: EXAMPLE: |