Home  >  Article  >  Backend Development  >  相关于thinkphp文本字段自增

相关于thinkphp文本字段自增

WBOY
WBOYOriginal
2016-06-13 12:51:34796browse

有关于thinkphp文本字段自增
我要做到的效果是
UPDATE `com_cn_selldetail` SET `remark`=remark+'今天多少号' WHERE id=62322

请问这种用TP怎么写。
我用array('exp',"remark+'今天多少号'");
打印出来是:
UPDATE `com_cn_selldetail` SET `remark`=remark+\'今天多少号\' WHERE id=62322


------解决方案--------------------
通过 tp 是做不到的,除非你去修改他的 model 类代码
即便是可以做到,你的 SQL 指令也是错的

文本字段累加,要用 concat
remark=concat(remark,'今天多少号')
------解决方案--------------------
引用:
引用:通过 tp 是做不到的,除非你去修改他的 model 类代码
即便是可以做到,你的 SQL 指令也是错的

文本字段累加,要用 concat
remark=concat(remark,'今天多少号')

可以说一下,这个在TP中要怎么写。

楼上已经说你用直接相加是做不到了,MYSQL中+只能加数字,字符串连接是用concat方法。你这种只能先取出数据,然后用PHP连接后再更新回去。
不过我搞不懂你这个是什么需求,怎么会有人往数据库字段中后面添加一段中文的需求?如果你是所有数据改字段都要加这段中文,那么我建议你直接在MYSQL中运行去掉条件的UPDATE语句。
Statement:
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