thinkphp操作mysql json字段

    /**
     * @throws \think\Exception
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     * @throws \think\exception\PDOException
     */
    function test() {

        // 查询
        $ret = Db::name('json')->where('fvalue->name', 'lobtao')->select();
        var_dump($ret);
        // 修改
        $ret = Db::name('json')->where('fvalue->name', 'lobtao')->update([
            'fvalue->name' => '深圳',
        ]);
        var_dump($ret);
        $ret = Db::name('json')->select();
        var_dump($ret);

    }

 

posted @ 2020-01-18 12:01  lobtao  阅读(1198)  评论(0)    收藏  举报