appending record instead of replacing field |
I am trying to update one field of a table.
PHP Code: $userid=$this->session->userdata('userid');
proof that an old dog can learn new tricks
@richb201,
Based on the CI documentation ( https://www.codeigniter.com/user_guide/d...ating-data ) replace is basically the SQL standard for (optional) DELETE + INSERT, using PRIMARY and UNIQUE keys... What you need to do is what you stated in your first sentence. You need to do an update to the table on a specific column where email equals a specific email address.
Thanks. I did see that. I was thinking that perhaps the issue was that the field I am trying to update is not primary. I did make it unique. You can see that the id is already primary and I can't have two primaries. Is there a better way to do this other than replace? Or should I manually do a delete and then an insert?
proof that an old dog can learn new tricks
I solved it by using:
$userid=$this->session->userdata('userid'); $campaign=$this->session->userdata('campaign'); $this->db->set('campaign', $campaign); $this->db->where('email', $userid); $this->db->update('users');
proof that an old dog can learn new tricks
|
Welcome Guest, Not a member yet? Register Sign In |