0

我有 3 个应用程序共享一个 codeigniter 安装的项目。在我更改 mysql 表的名称并更改查询以反映对数据库的新更改之前,它一直运行良好。现在看起来我的插入查询已被缓存,并试图将值插入旧表(不再存在)。这是我迄今为止尝试过的:

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

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

4

1 回答 1

0

I found answer to my problem, I had ON BEFORE INSERT/UPDATE triggers on my table, and when I changed it's name it turns out that inserting on the same table with new name was still triggering old table name instead of new one. So I just updated triggers and now it's working. Hope this will save time for someone else, because it took me a while even if it's looking trivial from this point of view now.

于 2013-09-23T18:46:57.287 回答