fastadmin thinkphp5 查询mysql的json格式字段

mysql5.7之后,支持了json格式的字段。

但是存的json怎么查询呢?难道要用like?

不可能这么不智能。

mysql直接查询

1. 字段->’$.json属性’进行查询条件

select * from json_test where str->'$.age' = '15'

2. 使用json_extract函数查询,json_extract(字段,”$.json属性”)

select * from json_test where json_extract(str,"$.age")

thinkphp5 fastadmin 把json格式字段的内容当做条件。

db(‘json_test’)->where(‘str$.age’,’15’)->find();

You May Also Like

About the Author: 萌新

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注