Codigniter 活动记录更新查询采用旧的 where 子句

发布于 2025-01-07 11:43:27 字数 429 浏览 3 评论 0原文

我有一个以下查询

$this->db->set('registerStep', $param)
 ->where('id = ',$user_id)
 ->update($this->table_name);

上面的查询正在生成下面的 sql 代码。即使我只提供一个条件。

 UPDATE `users` SET `registerStep` = 2 WHERE `id` = 33 AND `id` = '165'

我认为活动记录正在使用一些缓存的 where 条件,有什么方法可以释放 where 条件。
我尝试使用

$this->db->flush_cache();

但这没有帮助。

I have a following query

$this->db->set('registerStep', $param)
 ->where('id = ',$user_id)
 ->update($this->table_name);

Above Query is producing below sql code. even though I'm supplying only one where condition.

 UPDATE `users` SET `registerStep` = 2 WHERE `id` = 33 AND `id` = '165'

I think active record is using some cached where condition, is there any way I can free where condition.
I tried using

$this->db->flush_cache();

But it's not helping.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

何必那么矫情 2025-01-14 11:43:27

http://codeigniter.com/user_guide/database/active_record.html#update

->where('id = ',$user_id)

是不正确的。

->where('id',$user_id)

是正确的。

http://codeigniter.com/user_guide/database/active_record.html#update

->where('id = ',$user_id)

is incorrect.

->where('id',$user_id)

is correct.

失退 2025-01-14 11:43:27

您的查询完全正确。但我相信您在当前查询之前使用了 $this->db->where() 。使用以下代码,您将看到所有先前定义的“where”语句:

print_r($this->db->ar_where);
$this->db->set('registerStep', $param)
     ->where('id = ',$user_id)
     ->update($this->table_name);

Your query is fully correct. But I believe what you used a $this->db->where() before current query. Use the following code and you will see all the previously defined "where" statements:

print_r($this->db->ar_where);
$this->db->set('registerStep', $param)
     ->where('id = ',$user_id)
     ->update($this->table_name);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文