multiple where condition codeigniter

前端 未结 7 1050
感情败类
感情败类 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:16

    you can try this function for multi-purpose

    function ManageData($table_name='',$condition=array(),$udata=array(),$is_insert=false){
    $resultArr = array();
    $ci = & get_instance();
    if($condition && count($condition))
        $ci->db->where($condition);
    if($is_insert)
    {
        $ci->db->insert($table_name,$udata);
        return 0;
    }
    else
    {
        $ci->db->update($table_name,$udata);
        return 1;
    }
    

    }

提交回复
热议问题