php - Codeigniter 事件记录查询已缓存 - 查找旧表名而不是新表名

标签 php mysql codeigniter caching activerecord

我的项目有 3 个应用程序共享一个 codeigniter 安装。它工作得很好,直到我更改了 mysql 表的名称,并更改了查询以反射(reflect)数据库的新更改。现在看起来我的插入查询已被缓存,并尝试将值插入旧表(不再存在)。这是我到目前为止所尝试过的:

CI:

$this->db->cache_delete_all()

mysql:

RESET QUERY CACHE;

在config/database.php中:

$db['default']['db_debug'] = TRUE; 
$db['default']['cache_on'] = FALSE;

当 db_debug 配置设置为 TRUE 时,它会给出 500 错误,当设置为 FALSE 时,我能够捕获错误,结果发现它正在尝试插入到不再存在的旧表中。我不明白这怎么可能,我什至搜索了我的整个项目,但在我的项目中的任何地方都找不到旧的表名,而且 CI 缓存文件夹是空的。任何帮助将不胜感激。

编辑:我的插入代码:

if($this->db->insert('booking_calendar', $data))
{
    $booking_id = $this->db->insert_id();           
    $this->load->helper('string');


    $order_id = strtoupper(random_string('alnum', 6)) . $booking_id;


    $data = array(
      'id'                  => $order_id,
      'booking_calendar_id' => $booking_id,
      'status'              => 'PAYMENT_PENDING'                            
    );

    if($this->db->insert('bookings', $data))
    {
        $this->notifications->add($MYSELF['id'], 'Court successfully booked.');
        return $order_id;   
    }

    $this->notifications->add($MYSELF['id'], 'Court booking failed.', 'warning');
    return false;
}
else
{               
    log_message('ERROR', 'Insert booking_calendar failed. ' . print_r($this->db->_error_message(), true));
}

这是我日志中的输出:

ERROR - 2013-09-23 20:05:13 --> Insert booking_calendar failed. Table 'tennis.courts_calendar' doesn't exist

通知是自定义类,仅在“通知”表中插入一行。

最佳答案

我找到了问题的答案,我的表上有 ON BEFORE INSERT/UPDATE 触发器,当我更改它的名称时,结果发现使用新名称在同一个表上插入仍然会触发旧表名而不是新表名。所以我刚刚更新了触发器,现在它可以工作了。希望这能为其他人节省时间,因为即使从现在的角度来看这看起来微不足道,我也花了一段时间。

关于php - Codeigniter 事件记录查询已缓存 - 查找旧表名而不是新表名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18948248/

相关文章:

php - 发送 HTTP 响应后继续 PHP 执行

php - 在 Symfony 1.4 和 Doctrine 中使用一个查询插入多行

php - 无法使用 PHP 从 MySQL 数据库提取所有数据

javascript - 如何使用 Javascript 访问 CodeIgniter session cookie?

php - Codeigniter - 如何将数据库结果垂直显示为列而不是行

php - 在自动增量列中保留一组 id

php - 如果购物车包含特定的 Woocommerce 产品类别,则阻止添加到购物车

mysql - Mysql 中的存储过程不接受输入参数

php - 为 ul() codeigniter helper 转换数组结构

php - MYSQL 使用 SUM() 选择查询