think-orm icon indicating copy to clipboard operation
think-orm copied to clipboard

thinkorm + thinkcache ->cache(true) error

Open try-to opened this issue 2 years ago • 2 comments

error: Return value of think\db\PDOConnection::pdoQuery() must be of the type array, bool returned file: /vendor/topthink/think-orm/src/db/PDOConnection.php line: 695

old

if ($query->getOptions('cache')) {
    // 检查查询缓存
    $cacheItem = $this->parseCache($query, $query->getOptions('cache'));
    $key       = $cacheItem->getKey();

    $data = $this->cache->get($key);

    if (null !== $data) {
        return $data;
    }
}

new

if ($query->getOptions('cache')) {
    // 检查查询缓存
    $cacheItem = $this->parseCache($query, $query->getOptions('cache'));
    $key       = $cacheItem->getKey();

    $data = $this->cache->get($key, null);

    if (null !== $data) {
        return $data;
    }
}

try-to avatar Aug 02 '22 10:08 try-to

think\facade\Db::setCache(\think\facade\Cache::store());

$user = User::where('id', 1)->cache(60)->find();

try-to avatar Aug 02 '22 10:08 try-to

确实是这样的.我刚刚也遇到了同样的问题.希望官方改一下. @liu21st

momoca avatar Aug 04 '22 03:08 momoca