1

I have an update query which I use for keeping log of actions by appending to existing column data. It works fine if directly executed from phpmyadmin but doesn't work from Codeigniter. Please help.

$query=$this->db->set('log','CONCAT(log,"check")',FALSE);
$query=$this->db->where('label_id',3)->update('labels_table');

Above query executes but instead of appending, it replaces the content of log(Type=text)

4
  • This looks like it might help you do just that - stackoverflow.com/questions/7162509/…. Make sure you read it all :) Commented Apr 8, 2019 at 9:11
  • @TimBrownlaw Thanks for suggestion but it doesn't answer my question. why is it not working in codeigniter( active records)? Commented Apr 8, 2019 at 9:48
  • Found the issue. it was to do with my 'replace' statement which I was executing before this query. it was wiping out the log field. Thanks for your help. Commented Apr 8, 2019 at 9:59
  • As a debugging helper, you could replace $this->db->update('labels_table'); with echo $this->db->get_compiled_update('labels_table'); to get the compiled update statement without executing the query itself. Commented Apr 8, 2019 at 10:05

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.