Codeigniter -> function using empty_table
/** * Empty Table * * Compiles a delete string and runs "DELETE FROM table" * * @param string the table to empty * @return object */public function empty_table($table = '')
Apparently you can't do this
$this->db->empty_table('companyDetails,hostingDetails,layoutDetails');
Instead you will have to call empty_table
three times:
$this->db->empty_table('companyDetails');$this->db->empty_table('hostingDetails');$this->db->empty_table('layoutDetails');
You can always hack CodeIgniter DB_active_rec.php file so that it fits your needs.
In your controller you have to load the model first (if it's not auto loaded)
$this->load->model('quote'); // Assuming your model name is 'quote'
before you use the function from that model as you used in your controller as follows
$data['companyContact'] = $this->quote->getCompanyDetails()->companyContact;
and load the view at last, after all code has been executed even after following line
$this->quote->removeQuote();
Just checked in CI
doc empty_table
doesn't accept multiple table names.
SOLUTION ONE
$this->db->truncate('companyDetails');$this->db->truncate('hostingDetails');$this->db->truncate('layoutDetails');
SOLUTION TWO
function emptytablesbycomma($stringoftables) { $array_tablenames = explode(",", $stringoftables); if (!empty($array_tablenames)) { foreach ($array_tablenames as $tablename) { $this->db->truncate($tablename); } } }
Usage
$stringoftables='companyDetails,hostingDetails,layoutDetails';$this->emptytablesbycomma($stringoftables);