gpt4 book ai didi

laravel - Laravel查询生成器whereJson包含错误

转载 作者:行者123 更新时间:2023-11-29 13:42:35 24 4
gpt4 key购买 nike

我遇到了以下问题。
当我尝试使用新函数时,其中jsonContains来自laravel query builder,我得到以下错误:

SQLSTATE[42703]: Undefined column: 7 ERROR: column "json_contains" does not exist LINE 1: select * from "users" where "json_contains" = $1 ^ (SQL: select * from "users" where "json_contains" = 'test')

使用以下行
$result =DB::table('users')
->whereJsonContains('public_data->vakgebieden', 'schoonmaak')
->get();

这是存储在公共数据列postgress中jsonb中的数据。
{"vakgebieden": ["administratie", "onderwijs", "schoonmaak", "overheid", "industrie"]}

你知道这是怎么回事吗?
塔克斯

最佳答案

你用的是哪一个版本,你用的是哪一个数据库?
考虑一下:
Laravel还支持在支持JSON列类型的数据库上查询JSON列类型。目前,这包括MySQL 5.7、PostgreSQL、SQL Server 2016和SQLite 3.9.0(带有JSON1扩展)。要查询JSON列,请使用->运算符:
https://laravel.com/docs/5.7/queries#json-where-clauses

关于laravel - Laravel查询生成器whereJson包含错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53042868/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com