GatewayWorker Db类可以实现字段加1操作么?

huxiaohaiyang
$db = Db::instance('development');
$db->update('mailList')->cols(array('status'=>1,'times'=>'times'+1))->where('id='.$id)->query();
Workerman中这样写报错

zend 中可以这样写:
$db = Zend_Db_Table::getDefaultAdapter();
$where = $db->qutoInto('id = ?',$id);
$db->update('mailList',array('status'=>1,'times'=>new Zend_Db_Expr('times+'.1)),$where)

还是只能取的时候多取一个字段加
$db->update('mailList')->cols(array('status'=>1,'times'=>$times+1))->where('id='.$id)->query();

update mailList set status=1, times = times+1 where id =1;
2726 3 0
3个回答

huxiaohaiyang

不支持MarkDown,不知道代码怎么贴了

  • 暂无评论
walkor

直接写sql吧,那个DB类支持直接写sql的

walkor

或者试下
$db->update('mailList')->cols(array('status'=>1,'times'=>'times+1'))->where('id='.$id)->query();

年代过于久远,无法发表回答
🔝