如何在codeigniter中使用updateBatch方法来更新现有的DB字段数据+< Value>?

hts6caw3  于 7个月前  发布在  其他
关注(0)|答案(1)|浏览(68)

我想通过向数据库字段添加一些值来增加数据库列中的现有值?在通常的SQL查询中,我们可以这样做:

UPDATE user_master SET votes = votes + 1234 WHERE id = 1000;

字符串
但我想知道如何在传递给updateBatch方法的数据数组中执行此操作
我试着像:

$array['id'] = 1000; 
$array['votes'] = 'votes' + 1234;
$builder = $this->db->table('user_master');
$builder -> updateBatch($array, 'id');

lztngnrs

lztngnrs1#

基于Codeigniter 3官方文档
你可以试试这个,我从来没有试过:

<?php

$this->db->set_update_batch('votes', 'votes' + 1234, true);
$this->db->update_batch('user_master', null, 'id');

字符串

相关问题