如何“复位”连续查询的CodeIgniter活动记录? [英] How to "reset" CodeIgniter active record for consecutive queries?

查看:78
本文介绍了如何“复位”连续查询的CodeIgniter活动记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用CodeIgniter,并且有两个表(项目和任务)需要更新一个值(活动列需要设置为n)。我使用的代码是:

I'm using CodeIgniter and have a case where two tables (projects and tasks) need to be updated with a value right after one another (active column needs to be set to "n"). The code I am using is:

function update($url, $id)
{
    $this->db->where('url', $url);
    $this->db->update('projects', array('active' => 'n'));
    $this->db->where('eventid', $id);
    $this->db->update('tasks', array('active' => 'n'));
}

使用此代码,项目表更新,但任务表不更新。如果我注释掉$ this-> db-> update('projects',array('active'=>'n'));然后任务表被更新。

With this code, the projects table gets updated but the tasks table does not. If I comment out $this->db->update('projects', array('active' => 'n')); then the tasks table gets updated.

我认为这与缓存有关,但我已经尝试flush_cache之前的任务db->更新调用,但没有任何效果。

I reckon this has something to do with caching but I have tried flush_cache before the tasks db->update call but that didn't have any effect.

有人可以解释如何使用CodeIgniter执行连续更新查询?

Can someone explain how consecutive update queries can be executed using CodeIgniter?

推荐答案

使用

$this->db->start_cache();

开始查询构建之前和

$this->db->stop_cache();

结束查询构建之后。另外,使用

After ending query building. Also, use

$this->db->flush_cache();

停止缓存后。

这篇关于如何“复位”连续查询的CodeIgniter活动记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆