在 codeigniter 使用活动记录中更新限制为 1 [英] Update with limit 1 in codeigniter use active record

查看:23
本文介绍了在 codeigniter 使用活动记录中更新限制为 1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 codeigniter 的活动记录更新单个记录,但它仍然失败.

I'm trying to update a single record with the active record of codeigniter and it still fails.

$data = array('status' => 1);

$this->db->where('field1', $info);
$this->db->update('example', $data);
$this->db->limit(1);

当我运行时更新数据库的所有字段.通过制作 $ this->db->last_query() 不显示限制

When i run updates all fields of the database. By making a $ this->db->last_query() does not show me the limit

错误是什么

推荐答案

在更新之前移动应该总是最后调用的限制:

Move the limit before the update which should be always called last:

$this->db->limit(1);
$this->db->update('example', $data);

这篇关于在 codeigniter 使用活动记录中更新限制为 1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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