如何将此查询转换为活动记录?
"UPDATE table_user
SET email = '$email', last_ip = '$last_ip'
where username = '$username' and status = '$status'";
我尝试将上面的查询转换为:
$data = array('email' => $email, 'last_ip' => $ip);
$this->db->where('username',$username);
$this->db->update('table_user',$data);
使用 where 子句状态怎么样?
# must i write db->where two times like this?
$this->db->where('username',$username);
$this->db->where('status',$status);
我也尝试过这个:
$this->db->where('username',$username,'status',$status);
您可以使用数组并传递该数组。
Associative array method:
$array = array('name' => $name, 'title' => $title, 'status' => $status);
$this->db->where($array);
// Produces: WHERE name = 'Joe' AND title = 'boss' AND status = 'active'
或者如果您想做 = 比较以外的事情
$array = array('name !=' => $name, 'id <' => $id, 'date >' => $date);
$this->db->where($array);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)