Not sure if this is the cause of your problem, but you are using single quotes in the following lines:
$this->db->set('points', 'points + $points');
With this, the string $points will be entered literally into your SQL query - this is not its value that will be used.
If you want $points be interpolated (so its value is put in its place on this line), you should use double quotes:
$this->db->set('points', "points + $points");
For more information about the interpolation variable, see Variable Analysis in the PHP Manual.
Pascal martin
source share