Welcome Guest, Not a member yet? Register   Sign In
How to use $this->db->empty_table() for many tables?
#2

[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
$tables = array('table1','table2') ;
foreach($tables AS $table) {
     $this->db->empty_table($table);
     echo "$table emptied<br />";
}
?&gt;

From the manual:
Quote:$this->db->empty_table();

Generates a delete SQL string and runs the query.

Code:
&lt;?php
$this->db->empty_table('mytable');
?&gt;
// Produces
// DELETE FROM mytable

EDIT:
Wouldn't it be better to run $this->db->truncate(); instead? I'm not sure...


Messages In This Thread
How to use $this->db->empty_table() for many tables? - by El Forum - 04-06-2010, 02:40 PM
How to use $this->db->empty_table() for many tables? - by El Forum - 04-06-2010, 02:49 PM
How to use $this->db->empty_table() for many tables? - by El Forum - 04-06-2010, 02:49 PM



Theme © iAndrew 2016 - Forum software by © MyBB