multiple where condition codeigniter

前端 未结 7 1044
感情败类
感情败类 2021-02-01 15:16

How can I convert this query to active record?

\"UPDATE table_user 
 SET email = \'$email\', last_ip = \'$last_ip\' 
 where username = \'$username\' and status =         


        
7条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-01 16:07

    you can use an array and pass the array.

    Associative array method:
    $array = array('name' => $name, 'title' => $title, 'status' => $status);
    
    $this->db->where($array); 
    
    // Produces: WHERE name = 'Joe' AND title = 'boss' AND status = 'active'
    

    Or if you want to do something other than = comparison

    $array = array('name !=' => $name, 'id <' => $id, 'date >' => $date);
    
    $this->db->where($array);
    

提交回复
热议问题