CodeIgniter Forums

Full Version: Converting a query using the Query Builder
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have a query that right now is just a regular query executing via query(), I wanted to convert it using the Query Builder class

Heres the query as is:
PHP Code:
self::$db->query("UPDATE {$partition_table} SET {$column_name}=REPLACE({$column_name}, '{$current_value}', '{$new_value}') WHERE FIND_IN_SET('{$current_value}', {$column_name}) > 0" 

And that works fine, This is what I tried to convert it to:
PHP Code:
self::$db
    
->where("FIND_IN_SET('{$current_value}', {$column_name}) >"'0')
    ->
set($column_name"REPLACE({$column_name}, '{$current_value}', '{$new_value}')")
    ->
update($partition_table

And while that doesn't throw any errors, it will clean out the contents of any row it attempts to update...

Any idea what im doing wrong?

P.S. Before anyone says that it might be how I'm trying to use FIND_IN_SET, I've gotten it to work before, like so:
PHP Code:
$query self::$db
    
->where_in('page_id', (is_array($pages) ? $pages : [$pages]))
    ->
where("FIND_IN_SET('{$partition}', partitions) >"'0')
    ->
get('pages'); 
Nvm, I got it working by just disabling the escape
PHP Code:
self::$db
    
->where("FIND_IN_SET('{$current_value}', {$column_name}) >"'0'FALSE)
    ->
set($column_name"REPLACE({$column_name}, '{$current_value}', '{$new_value}')"FALSE)
    ->
update($partition_table