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

Hi everyone,

Here is a mysql query i have in my application:

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:

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


why not use:
$query = $this->db->query('YOUR QUERY HERE');

I thought that maybe there is a seperate function for that but i guess not

Theme © iAndrew 2016 - Forum software by © MyBB