How to update all rows in database using batch update? - 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: How to update all rows in database using batch update? (/showthread.php?tid=61497) |
How to update all rows in database using batch update? - paju89 - 04-20-2015 I want to update database and add slug to every row. Problem is the code i wrote only update 1 row. here is the structure of database site_id integer primarykey autoincrement site_title varchar slug varchar this is my controller here i make slug from title i get from database and want to update all row and insert new slug to every row PHP Code: public function ghjk(){ this is my model PHP Code: function updateall($data,$slug){ RE: How to update all rows in database using batch update? - silentium - 04-20-2015 Hi, I would do something like this. Added comments to the code to try and make it clear how it works. Controller PHP Code: function ghjk() Model PHP Code: function updateall($data = array()) A small note. In your original code you load the model twice in the same controller function. You only need to load it once, so I removed the second loading in my example. RE: How to update all rows in database using batch update? - paju89 - 04-21-2015 (04-20-2015, 03:00 PM)silentium Wrote: Hi, Thank you very much man. It worked like a charm. It took my day but you saved me thanks. |