国产+高潮+在线,国产 av 仑乱内谢,www国产亚洲精品久久,51国产偷自视频区视频,成人午夜精品网站在线观看

webman使用thinkorm加cache的時候會報錯

鄒意

運行環(huán)境,php8.2:

截圖

問題1:

使用thinkorm,字段content是存的數(shù)組序列化后的值,模型加了獲取器的
獲取器:
public function getContentAttr($value)
{
return $value ? unserialize($value) : [];
}

模型方法:

public function getConfig($id = null)
{
    $id = $id ?? request()->get('id') ;
    if(! $id) abort('參數(shù)錯誤');
    $data = $this->cache(true)->where('id',$id)->field('content')->find();
    return $data['content'] ?? [];
}

只有第一次調(diào)用會報錯,如果把緩存去了就不會報錯:
截圖

問題2:

如果把模型方法改成這樣:

public function getConfig($id = null)
{
    $id = $id ?? request()->get('id') ;
    if(! $id) abort('參數(shù)錯誤');
    //修改了這,把find改為value
    $data = $this->cache(true)->where('id',$id)->value('content');
    return $data ?? [];
}

這樣問題就更大了,查詢出來$data等于null,更別說緩存了

這兩個問題我專門用thinkphp下測試了下,都不會出現(xiàn)

849 1 0
1個回答

JackDx

thinkcache.php設(shè)置調(diào)加:'serialize' => ['serialize', 'unserialize']試一試,好像是thinkcache兼容性問題,你PHP版本降低看看 如7.4

  • 鄒意 2023-09-22

    第一個問題能解決,第二個問題依然存在

  • JackDx 2023-09-22

    應該thinkcache兼容性問題,我看thinkcache倉庫有相同問題反饋,但是沒有修復

  • yzh52521 2023-09-22

    自己維護一版吧

年代過于久遠,無法發(fā)表回答
??