Welcome Guest, Not a member yet? Register   Sign In
active record CONCAT

Anyone know how to CONCAT an existing text field with new text using Active Record? Is this possible?

I'll explain that a little better. I have a field in one of my tables called "log" which has existing text in it, and I wish to append text such as "updated on 12 Feb 08" to the end of this field. I know I could query the database to return the record and extract the field text, and then update the table it with the new concatanated text, but that seems an awful long way of doing something simple.

I believe I can do something like
$this->db->set('field', 'field+1', FALSE);
for numeric fields, but how about text?

Did you try the concat function?
$this->db->set('field', 'CONCAT(field,field2)', FALSE);

It should be noted, however, that CONCAT is database specific. It's not actually a part of the active record library, although I'm sure it's supported by most, if not all database engines.

Thanks xwero, that worked a treat.

Theme © iAndrew 2016 - Forum software by © MyBB