0
$array=array(
 'amount'=>$this->input->post('netamt'),
 'trandate'=>$billdate,
 'crcode'=>$this->input->post('rcode')
  );
  $this->db->where('voucher',$this->input->post('billno'));
  $this->db->like('code','16','after');
  $this->db->update('tranachst',$array);

when display this query using echo $this->db->last_query();

UPDATE `tranachst` SET `amount` = '717360', `trandate` = '2015-07-15', `crcode` = '311001' WHERE `voucher` = '15020'

here like query not working , why ?

codelover
  • 131
  • 1
  • 10

2 Answers2

1

Please Try This --

My Exmaple --

$this->db->where('faq_id', $id);
$this->db->where('question LIKE ', '%do%'); 
$this->db->update('admin_faqs', $data);

Your Example --

$array=array(
 'amount'=>$this->input->post('netamt'),
 'trandate'=>$billdate,
 'crcode'=>$this->input->post('rcode')
  );
  $this->db->where('voucher',$this->input->post('billno'));
  $this->db->where('code LIKE ', '16%'); 
  $this->db->update('tranachst',$array);

In this code you don`t need to use after, before parameter please try this..

Sorav Garg
  • 1,116
  • 1
  • 9
  • 26
0

Some people have the same question, and until now i don't know why. but clearly CI didn't support active record like above.

you can use $this->db->query() or

function index(){
    $this->load->database();
    $data=array(
        'userlogin'=>'test'
    );
    $this->db->where('userlogin','xx');
    $this->db->where("email like 'xx'");
    $q=$this->db->update('master_user',$data);

}

something like that work too. the same question : CodeIgniter Active Record 'like' ignoring 'where'

Community
  • 1
  • 1
Rifai
  • 194
  • 11