Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql error #273

Closed
dayrui opened this issue Sep 23, 2016 · 1 comment
Closed

sql error #273

dayrui opened this issue Sep 23, 2016 · 1 comment

Comments

@dayrui
Copy link

dayrui commented Sep 23, 2016

$builder = $db->table('mytable');
$builder->set('field', 'field+1', FALSE);
$builder->where('id', 2);
$builder->update(); // gives UPDATE mytable SET field = field+1 WHERE id = 2

($builder->set('field', 'field+1', FALSE);) this is bug !!!!

error: UPDATE mytable SET field = 'field+1' WHERE id = 2

@lonnieezell
Copy link
Member

Yeah, those situations have always been painful for CI's Query Builder IIRC. I got to where I was writing those queries manually.

However, there's new increment() and decrement() methods in Query Builder you can use instead:

$db->table('mytable')
    ->where('id', 2)
    ->increment('field', 1);

Note that these do run the query right then, though...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants