Welcome Guest, Not a member yet? Register   Sign In
Using string replace function of mysql with CI active record class
#1

[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...
#2

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

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




Theme © iAndrew 2016 - Forum software by © MyBB