CodeIgniter Forums
Using string replace function of mysql with CI active record class - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Using string replace function of mysql with CI active record class (/showthread.php?tid=22533)



Using string replace function of mysql with CI active record class - El Forum - 09-12-2009

[eluser]Unknown[/eluser]
Hi everyone,

Here is a mysql query i have in my application:

Code:
UPDATE items SET item_name = REPLACE(item_name, 'ipod', 'iPod') WHERE item_name LIKE 'ipod%'

Note: This is not the exact sql query i am running. I have changed fields names and data for this example.

Is there a way for me to run this query with active record class. Something like:

Code:
$this->db->like('item_name', 'ipod', 'after');
$this->db->update('items', array('item_name' => "REPLACE(item_name, 'ipod', 'iPod')");

thanks...


Using string replace function of mysql with CI active record class - El Forum - 09-12-2009

[eluser]sophistry[/eluser]
why not use:
Code:
$query = $this->db->query('YOUR QUERY HERE');



Using string replace function of mysql with CI active record class - El Forum - 09-13-2009

[eluser]Unknown[/eluser]
I thought that maybe there is a seperate function for that but i guess not