Welcome Guest, Not a member yet? Register   Sign In
MYSQL Functions
#1

[eluser]vtafsar[/eluser]
I want to use some mysql functions on field values(on $data) like SUM, CONCAT, REPLACE etc ...

Is it possible to do on '$this->db->update('mytable', $data, array('id' => $id));' without manually creating the query?

--
Thank You.
#2

[eluser]demogar[/eluser]
I really don't understand your question but I think you should read the manual under the Database Class -> Active Record Class.

Regards.
#3

[eluser]vtafsar[/eluser]
Yes. I have already read active record class manual.
What I need is to run a query like:

UPDATE table_name SET field_name2=CONCAT(field_name2, "Some content") WHERE field_name1=1;

I tried the following code,

==================================================================
$this->db->where(field_name1, 1);
$this->db->update(table_name, array('field_name2'=> "CONCAT(field_name2, \"Some content\")"));
==================================================================

but it is not updating the field like what I am looking for.
Hope now you understand what is my question.

Thank You
#4

[eluser]jedd[/eluser]
[quote author="vtafsar" date="1259578380"]
but it is not updating the field like what I am looking for.
[/quote]

Do you know if it's not updating because the query is wrong, or because the data doesn't match?

You can confirm whether the query is okay by checking what AR turns your query into - the actual string that it sends to the database. The process for doing this is described in [url="/wiki/FAQ"]the FAQ[/url] - the first question in fact.




Theme © iAndrew 2016 - Forum software by © MyBB