Codeigniter - >使用empty_table的函数

Jes*_*zie 2 php mysql codeigniter

我试图清空表格,但我想知道我的功能是否正确?

模型:

public function removeQuote()
    {
        $this->db->empty_table('companyDetails,hostingDetails,layoutDetails');
    }
Run Code Online (Sandbox Code Playgroud)

控制器:

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

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

        $this->quote->removeQuote();
}
Run Code Online (Sandbox Code Playgroud)

错误:

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

DELETE FROM `companyDetails,hostingDetails,layoutDetails`
Run Code Online (Sandbox Code Playgroud)

nov*_*ato 10

/**
 * Empty Table
 *
 * Compiles a delete string and runs "DELETE FROM table"
 *
 * @param   string  the table to empty
 * @return  object
 */
public function empty_table($table = '')
Run Code Online (Sandbox Code Playgroud)

显然你不能这样做

$this->db->empty_table('companyDetails,hostingDetails,layoutDetails');
Run Code Online (Sandbox Code Playgroud)

相反,你将不得不打empty_table三次电话:

$this->db->empty_table('companyDetails');
$this->db->empty_table('hostingDetails');
$this->db->empty_table('layoutDetails');
Run Code Online (Sandbox Code Playgroud)

您可以随时破解CodeIgniter DB_active_rec.php文件,以满足您的需求.