Increment field of mysql database using codeigniter's active record syntax

前端 未结 3 918
粉色の甜心
粉色の甜心 2020-12-08 02:03

I have the following php-codeigniter script which attempts to increment a field of a record using active-record syntax:

$data = array(\'votes\' => \'(vote         


        
3条回答
  •  春和景丽
    2020-12-08 02:30

    $data = array('votes' => 'votes + 1');
    
    foreach ($data as $key=>$val) {
        $this->db->set($key, $val, FALSE);
    }
    
    $this->db->where('id', $post['identifier']);
    $this->db->update('users', $data);
    

提交回复
热议问题