Php – Codeigniter -> function using empty_table

codeigniterMySQLPHP

I am trying to empty the tables but I was wondering have I got the function correct?

Model:

public function removeQuote()
    {
        $this->db->empty_table('companyDetails,hostingDetails,layoutDetails');
    }

Controller:

public function submit()
{
        $data['companyContact'] = $this->quote->getCompanyDetails()->companyContact;

        $this->load->view('submit',$data);

        $this->quote->removeQuote();
}

Error:

Table '_quote.companyDetails,hostingDetails,layoutDetails' doesn't exist

DELETE FROM `companyDetails,hostingDetails,layoutDetails`

Best Answer

/**
 * 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.