![]() |
How to use $this->db->empty_table() for many tables? - 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: How to use $this->db->empty_table() for many tables? (/showthread.php?tid=29338) |
How to use $this->db->empty_table() for many tables? - El Forum - 04-06-2010 [eluser]shinokada[/eluser] I have 20 tables to empty. When I use it following the first one does not work. And the second method only empties the first table. What is the best way to empty many tables? Do I have empty one by one? Thanks in advance. Code: // first How to use $this->db->empty_table() for many tables? - El Forum - 04-06-2010 [eluser]troy_mccormick[/eluser] The manual only shows being able to pass in one table name at a time. Your best bet would be to loop through each table in that array like such: Code: <?php From the manual: Quote:$this->db->empty_table(); EDIT: Wouldn't it be better to run $this->db->truncate(); instead? I'm not sure... How to use $this->db->empty_table() for many tables? - El Forum - 04-06-2010 [eluser]danmontgomery[/eluser] Code: $tables = array ('table1','table2',...); |