Codeigniter使用增量更新mysql数据

I want to add 1 to my column named SIZE (integer), this is my query:

$this->dbsections->update('sections', "SIZE = SIZE + 1");

But in the error message, it reads as:

UPDATE `sections` SET `SIZE = SIZE +` 1 = '' WHERE `NAME` = 'ABC'

You can rewrite your update query

$this->dbsections->set('SIZE', 'SIZE+1', FALSE);// third parameter FALSE
$this->dbsections->where('NAME', "ABC");
$this->dbsections->update('sections');

set() will also accept an optional third parameter ($escape), that will prevent data from being escaped if set to FALSE

Read https://www.codeigniter.com/userguide3/database/query_builder.html#updating-data

You can try this:

$this->dbsections->query("UPDATE sections SET SIZE = SIZE + 1 WHERE NAME = 'ABC'");