【问题标题】:CodeIgniter active record update how do I do it compared to a SQL query?CodeIgniter 活动记录更新与 SQL 查询相比,我该怎么做?
【发布时间】:2011-07-07 07:42:34
【问题描述】:

通常在使用mysql查询时,我可以这样更新:

update tb_cash_wallet set close_amount=close_amount+5

如果使用 codeigniter,我该怎么做?

我的代码示例:

$data = array(
        'AMOUNT' => 0.0000,
        'DATEUPDATE' => $datetime,
        'FLAG' => 'Y',
        'CLOSE_AMOUNT' => $val->AMOUNT,         
        );

function close_account($data,$id)
{       
    $this->db->where('ID', $id);        
    return $this->db->update('tb_cash_wallet', $data);  
}

【问题讨论】:

    标签: php mysql database codeigniter


    【解决方案1】:

    这里:

    $this->db->set('close_amount', 'close_amount + 1', FALSE);
    $this->db->where('ID'=>$id);
    $this->db->update('tb_cash_wallet');
    

    编辑:字段名称不正确。

    【讨论】:

      猜你喜欢
      • 2021-02-23
      • 2016-03-10
      • 1970-01-01
      • 1970-01-01
      • 2015-07-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多