CodeIgniter-MY_Model
CodeIgniter-MY_Model copied to clipboard
Update increment
On the docs you mention that you can do this type of update where you can increment 1 field.
$this->update(array('wins'=>'wins+1'), array('user_id' => $user_id), FALSE);
Im getting this SQL syntax error when using this currently.
Error Number: 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL
server version for the right syntax to use near '20:11:14 WHERE `user_id` = 1' at line 1
UPDATE `stat` SET wins = wins+1, updated_at = 2015-12-11 20:11:14 WHERE `user_id` = 1
Filename: core/MY_Model.php
Line Number: 487
Ive tried without the optional FALSE param and I no longer get the SQL error but it just updates the field to 0 rather than incrementing it.
Just wanted to check back in on this. Havent heard back about the incrementer method.
Quick fix; line 506 and 558
if($this->timestamps !== FALSE) { $data[$this->_updated_at_field] = $this->_the_timestamp(); if(!$escape) $data[$this->_updated_at_field] = "'" . $data[$this->_updated_at_field] . "'"; }