is_unique for codeigniter form validation

前端 未结 9 1073
走了就别回头了
走了就别回头了 2020-12-03 07:19

I\'m trying to figure out how I can use the is_unique rule from the Codeigniter form validation library in the following situation.

I\'m trying to submi

9条回答
  •  时光取名叫无心
    2020-12-03 08:04

    Simple Way

    Just Change isset to is_object in system/libraries/form_validation.php

    public function is_unique($str, $field)
    {
        sscanf($field, '%[^.].%[^.]', $table, $field);
        return is_object($this->CI->db) //default isset
            ? ($this->CI->db->limit(1)->get_where($table, array($field => $str))->num_rows() === 0)
            : FALSE;
    }
    

提交回复
热议问题