作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我遇到了以下问题。
当我尝试使用新函数时,其中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();
{"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/
我是一名优秀的程序员,十分优秀!