code formatting help - 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: code formatting help (/showthread.php?tid=51472) |
code formatting help - El Forum - 05-05-2012 [eluser]Samus[/eluser] Hi guys I need help formatting this code to make use of insert_batch(). My code looks abit like this: Code: if ($handle) : As you can see it is using insert() within the while loop to insert each line, which produces a sql query for each line, whereas I could probably do it all in one statement. Could someone suggest how I would re arrange the array to incorporate the use of insert_batch()? I have a feeling insert_batch would be appropriate outside the while loop, just not sure how to format the array? code formatting help - El Forum - 05-05-2012 [eluser]CroNiX[/eluser] It just needs to be an array of (insert) arrays. Right now you have a single (insert) array, $final. Change $final = array() to $final[] = array() and then outside of the while loop run the batch insert using $final. code formatting help - El Forum - 05-05-2012 [eluser]Samus[/eluser] [quote author="CroNiX" date="1336232031"]It just needs to be an array of (insert) arrays. Right now you have a single (insert) array, $final. Change $final = array() to $final[] = array() and then outside of the while loop run the batch insert using $final.[/quote] Thanks mate! All good. |