按值递增 Cakephp 数据库字段 [英] Incrementing Cakephp database field by a value

查看:24
本文介绍了按值递增 Cakephp 数据库字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个字段的值,我必须将字段值增加一个特定的值.我正在使用这个

I have this field whose value i have to increment the field value by a specific value. I am using this

$data['quantity']     = 'Order.quantity+1';

对我不起作用的数量是这里的整数列.当数据库中没有任何内容时它也可以工作吗?.

which doesnt works for me quantity is a integer coloumn here. Also will it work when nothing is in database?.

问候喜满树夏尔马

推荐答案

你可以使用 updateAll() 来解决这个问题

you can use updateAll() for this

通过谷歌搜索可以很快发现这一点:http://cakephp.1045679.n5.nabble.com/Auto-Increment-A-Field-td3491697.html

a little googling reveals this pretty quick: http://cakephp.1045679.n5.nabble.com/Auto-Increment-A-Field-td3491697.html

这篇关于按值递增 Cakephp 数据库字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆