jcadima
4/27/2020 - 9:19 PM

CI check if query was successful

ref: https://stackoverflow.com/questions/9913796/how-do-i-test-if-my-mysql-update-query-was-successful-in-codeigniter/19497495
<?php
$this->db->trans_start();
	$data = [
	    'password' => md5($password) ,
	    'reset_pass' => null,
	] ;
	$this->db->where('id_user', $id);
	$this->db->update('users', $data); // where $data will have the fields with values you are updating
$this->db->trans_complete();

if ($this->db->trans_status() === FALSE)
    return false;
return true;


OR


$this->db->from('customer_status') ;
$this->db->where('id_customer', $id_customer) ;
$this->db->order_by('id_customer_status', 'DESC') ;
  $this->db->limit(1);
$this->db->get()->row();
  return ($this->db->affected_rows() > 0);