fastadmin关联表 时间搜索提示表不存在

1.首先排查js文件和控制器文件的代码是否存在逻辑问题
2.如果正常则考虑是 日期时间条件解析的问题
打开文件
thinkphp/library/think/db/Builder.php第478行

/**
     * 日期时间条件解析
     * @access protected
     * @param string    $value
     * @param string    $key
     * @param array     $options
     * @param string    $bindName
     * @param integer   $bindType
     * @return string
     */
    protected function parseDateTime($value, $key, $options = [], $bindName = null, $bindType = null)
    {
        // 获取时间字段类型
        if (strpos($key, '.')) {
            list($table, $key) = explode('.', $key);
            if (isset($options['alias']) && $pos = array_search($table, $options['alias'])) {
                $table = $pos;
            } else {
                $prefix = config('database.prefix');
                if (strpos($table, $prefix) === false) {
                    $table = $prefix . $table;
                }
            }
        } else {
            $table = $options['table'];
        }
        $type = $this->query->getTableInfo($table, 'type');
        if (isset($type[$key])) {
            $info = $type[$key];
        }
        if (isset($info)) {
            if (is_string($value)) {
                $value = strtotime($value) ?: $value;
            }

            if (preg_match('/(datetime|timestamp)/is', $info)) {
                // 日期及时间戳类型
                $value = date('Y-m-d H:i:s', $value);
            } elseif (preg_match('/(date)/is', $info)) {
                // 日期及时间戳类型
                $value = date('Y-m-d', $value);
            }
        }
        $bindName = $bindName ?: $key;

        if ($this->query->isBind($bindName)) {
            $bindName .= '_' . str_replace('.', '_', uniqid('', true));
        }

        $this->query->bind($bindName, $value, $bindType);
        return ':' . $bindName;
    }


替换492行

            if (isset($options['alias']) && $pos = array_search($table, $options['alias'])) {
                $table = $pos;
            } else {
                $prefix = config('database.prefix');
                if (strpos($table, $prefix) === false) {
                    $table = $prefix . $table;
                }
            }

就可以了, 按理说官方不应该出这样的问题

标签:
作者:admin_rose
我只相信自己,终有一天会完成自己梦想中的事情
版权所有原创文章,转载请保留或注明出处:http://www.antvv.com/?id=24

已有 0 位网友参与,快来吐槽:

发表评论