Welcome Guest, Not a member yet? Register   Sign In
query builder class help
#1

Hello everybody,

I have a little question about the query builder class.
Using normal sql I'd do this

PHP Code:
Update table set val val 3 where id 1

How can i do the same thing with the query class ? The code below doesn't work

PHP Code:
$this->db->set(array('val' => 'val+1'))->where(array('id' => 1))->update('table'); 
thank you for helping !
Reply
#2

Disable auto escape may work:

PHP Code:
$this->db->set(array('val' => 'val+1'), ''FALSE)->where(array('id' => 1))->update('table');  
Reply
#3

You could just set a variable.

Code:
$val = $val + 1;
$this->db->set(array('val' => $val))->where(array('id' => 1))->update('table');
Reply
#4

That's right, with the third parameter i can do the update ! it's even on the manual..  Blush

But it doesn't work the query if i give as first parameter an array, second "blank" and third FALSE




The only way is to make value per value like this









PHP Code:
$this->set('field','field+1',FALSE
Reply




Theme © iAndrew 2016 - Forum software by © MyBB