Think/Model/ViewModel.php
protected function checkCondition(array $where = [])
    {
        if (is_array($where)) {
            $view = [];
            // 检查视图字段
            foreach ($this->viewFields as $key => $val) {
                $k = isset($val['_as']) ? $val['_as'] : $key;
                $val = $this->_checkFields($key, $val);
                foreach ($where as $name => $value) {
                    if (false !== $field = array_search($name, $val, true)) {
                        // 存在视图字段
                        $_key = is_numeric($field) ? $k.'.'.$name : $k.'.'.$field;
                        $view[$_key] = $value;
                        unset($where[$name]);
                    }
                }
            }
            $where = array_merge($where, $view);
        }

        return $where;
    }
protected function checkCondition(array $where = [])
    {
        if (is_array($where)) {
            $view = [];
            // 检查视图字段
            foreach ($this->viewFields as $key => $val) {
                $k = isset($val['_as']) ? $val['_as'] : $key;
                $val = $this->_checkFields($key, $val);
                foreach ($where as $name => $value) {
                    if (false !== $field = array_search($name, $val, true)) {
                        // 存在视图字段
                        $_key = is_numeric($field) ? $k.'.'.$name : $k.'.'.$field;
                        $view[$_key] = $value;
                        unset($where[$name]);
                    }
                }
            }
            $where = array_merge($where, $view);
        }

        return $where;
    }
检查条件中的视图字段


@param array $where 条件表达式

@return array