Welcome Guest, Not a member yet? Register   Sign In
Converting a query using the Query Builder
#1

(This post was last modified: 09-18-2015, 07:50 AM by jLinux.)

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'); 
Reply
#2

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
Reply




Theme © iAndrew 2016 - Forum software by © MyBB