Home > Database > Mysql Tutorial > codeigniter MySQL加减运算

codeigniter MySQL加减运算

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 15:47:21
Original
1417 people have browsed it

使用codeigniter更新MySQL时,如果要用到MySQL的加减运算,可以这样做: $this-db-set('field', 'field1', FALSE); $this-db-update('mytable'); 如果插入时要用到加减运算的话,可以用:$this-db-insert('mytable'); set() 也接受可选的第三个参数($escape)

使用codeigniter更新MySQL时,如果要用到MySQL的加减运算,可以这样做:

$this->db->set('field', 'field+1', FALSE);
$this->db->update('mytable');

如果插入时要用到加减运算的话,可以用:$this->db->insert('mytable');

set() 也接受可选的第三个参数($escape),如果此参数被设置为 FALSE,就可以阻止数据被转义。为了说明这种差异,这里将对 包含转义参数 和 不包含转义参数 这两种情况的 set() 函数做一个说明。

$this->db->set('field', 'field+1', FALSE);<br> $this->db->insert('mytable'); <br> // 得到 INSERT INTO mytable (field) VALUES (field+1)<br> <br> $this->db->set('field', 'field+1');<br> $this->db->insert('mytable'); <br> // 得到 INSERT INTO mytable (field) VALUES ('field+1')


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template