用户
 找回密码
 入住 CI 中国社区
搜索
查看: 4669|回复: 2
收起左侧

ar中如何让字段自加一呢

[复制链接]
发表于 2008-12-29 18:59:26 | 显示全部楼层 |阅读模式
我想让登录次数加一,如下好像不行,应是怎么用?

   $this->db->set('lastupdate',now());
   $this->db->set('loginnum','loginnum+1');
   $this->db->where('adminname',$username);
   $this->db->update('admin');
 楼主| 发表于 2008-12-29 21:08:06 | 显示全部楼层
解决了
$this->db->set('loginnum','loginnum+1',FALSE);
发表于 2009-2-17 11:13:57 | 显示全部楼层
set() will also accept an optional third parameter ($escape), that will prevent data from being escaped if set to FALSE. To illustrate the difference, here is set() used both with and without the escape parameter.

$this->db->set('field', 'field+1', FALSE);
$this->db->insert('mytable');
// gives INSERT INTO mytable (field) VALUES (field+1)

$this->db->set('field', 'field+1');
$this->db->insert('mytable');
// gives INSERT INTO mytable (field) VALUES ('field+1')

本版积分规则