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

[eluser]NZmuzzer[/eluser]
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
Code:
$this->db->set('field', 'field+1', FALSE);
for numeric fields, but how about text?
#2

[eluser]xwero[/eluser]
Did you try the concat function?
Code:
$this->db->set('field', 'CONCAT(field,field2)', FALSE);
#3

[eluser]TheFuzzy0ne[/eluser]
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.
#4

[eluser]NZmuzzer[/eluser]
Thanks xwero, that worked a treat.




Theme © iAndrew 2016 - Forum software by © MyBB