CodeIgniter单更新查询更新一列与现有列数据? [英] CodeIgniter single update query to update one column with an existing columns data?

查看:189
本文介绍了CodeIgniter单更新查询更新一列与现有列数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的数据库中,我有一个最后一个和当前列的datetime。只是为了保持注意,当有人最后一次使用有效的登录服务,我正在建立。



我想知道的是,可以更新一列



Ie:将最后一个设置为当前电流,然后使用

解决方案



<尝试这样..

  $ data = array('last_login'=> current_login,'current_login'=> date 'Ymd H:i:s')); 
$ this-> db-> where('id','some_id');
$ this-> db-> update('login_table',$ data);


In my db I have a Last and a Current column for datetime. Just to keep an eye on when someone last used a valid login to the service I am building up.

What I want to know is, is it possible to update one column on a row with another column from that row, while updating the other column at the same time

Ie: Set the Last as the current Current, then set the Current with the date thats right now essentially?

Make any sense?

解决方案

Try like this ..

$data=array('last_login'=>current_login,'current_login'=>date('Y-m-d H:i:s'));
$this->db->where('id','some_id');
$this->db->update('login_table',$data);

这篇关于CodeIgniter单更新查询更新一列与现有列数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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