php - Codeigniter -> 使用 empty_table 的函数

标签 php mysql codeigniter

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

型号:

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();
}

错误:

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

DELETE FROM `companyDetails,hostingDetails,layoutDetails`

最佳答案

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

显然你不能这样做

$this->db->empty_table('companyDetails,hostingDetails,layoutDetails');

相反,您必须调用 empty_table 三次:

$this->db->empty_table('companyDetails');
$this->db->empty_table('hostingDetails');
$this->db->empty_table('layoutDetails');

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

关于php - Codeigniter -> 使用 empty_table 的函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10067671/

相关文章:

mysql - 使用 mysql group by 和 where by date 返回计数 0

javascript - FullCalendar 在设定的时间内每周重复 mysql 事件

php - 将 URL 提交到没有 "http://"、有 "www."或两者都没有的表单中

php - 从数据库中删除内容,安全预防措施

javascript - 如何使用 html 模式验证澳大利亚电话号码

javascript - php中onclick后的mySQL请求

php - 在动态字段中显示提取数据

php - 是否可以使用 CodeIgniter 的查询生成器进行此查询?

php - 如何将php代码保存到数据库中

php - 将 JS 添加到 Codeigniter 链接 - 简单的 OnClick