php - Decreasing a column value using SET -
i'm trying use codeigniter's database classes decrease value of column. @ moment i'm doing this:
public function deduct_limit($bytes, $ip_address) { $this->db->where('ip_address', $ip_address); $this->db->set('limit', 'limit - ' . $bytes, false); $this->db->update('limits'); } however, codeigniter throws error message:
you have error in sql syntax; check manual corresponds mysql server version right syntax use near 'limit - 418266480
ip_address= '127.0.0.1'' @ line 1
update `limits` set `limit` = limit - 418266480 `ip_address` = '127.0.0.1' as far know sql correct, i've google'd , looked on , follow syntax. can not use other +1 or -1?
you need escape reserved words in mysql limit backticks
update limits set `limit` = `limit` - 418266480 ip_address = '127.0.0.1'
Comments
Post a Comment