唯一性验证失效?

浏览:583 发布日期:2015/06/27 分类:求助交流
array('uphone', '', 'used phone', 0, 'unique', 1)
无论给什么值给uphone,都返回false,而这些值在数据库中不存在。
_sql()出来是:sele ct * fr om ‘users’ li mit 1,没有where我要的uphone。

特地看了Model.class.php,在第1292行左右我添加了一行输出$map值:                print_r ($map);//测试用
                if($this->where($map)->find())   return false;
                return true;
输出:Array
(
    [uphone] => 11111111111
)
说明到这是没问题的,继续往下,去find那,第720行再添加一行:    public function find($options=array()) {
        print_r ($options);//测试用
    …...
输出:空。
而这个options应该是用来where的数组,看这个function的728行:        if (is_array($options) && (count($options) > 0) && is_array($pk)) {
//这里options是数组没问题,但options的count=0,pk是id好像也不是数组。
            // 根据复合主键查询
            $count = 0;
            foreach (array_keys($options) as $key) {
                if (is_int($key)) $count++; 
            } 
            if ($count == count($pk)) {
                $i = 0;
                foreach ($pk as $field) {
                    $where[$field] = $options[$i];
                    unset($options[$i++]);
                }
                $options['where']  =  $where;
//在这where,但因为上面的条件约束,根本到不了这里。
            } else {
                return false;
            }
        }
粗粗看了这么多,到底哪出了问题?
最佳答案
评论( 相关
后面还有条评论,点击查看>>