简体   繁体   中英

Can't update specific fields in mysql

I'm using the ion_auth for Codeigniter. I send the default values for active, sms_active as 0 and the default values for these fields are 0 but they get inserted as 1 I try to update these fields after the registration is successful but they don't get updated though I get the update success message. They are always 1 how to find ideas to solve this issue.

From the register function in ion_auth_model

$data = array(
    $this->identity_column   => $identity,
    'password'   => $password,
    'email'      => $email,
    'ip_address' => $ip_address,
    'created_on' => time(),
    'sms_active' => 0,
    'active'     => 0
);

In the controller after the registration is successful

$updated_data = array(
    'active'     => 0 ,
    'sms_active' => 0
);
$this->ion_auth->update($id, $updated_data);

I even tried updating values using Ajax from the view

$(function () {
      $.post("<?=base_url()?>users/register/deactivate",{'id':"<?=$id?>"});
});

$q="update users set active = 0, sms_active = 0 where id = '$id'";
$this->db->query($q);

Fields are tinyint(1) default 0

  1. If your table, this "trouble field" set default = 0, and for "the first time", value of that field = 0, better is don't include that field at $data
  2. Please check again table and your code script (specially ion_auth)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM