0
我有db表类别与列OctoberCMS DB查询和JSON
id name types active
- ID - INT,自动增加
- 名称 - VARCHAR
- 类型 - JSONABLE
- ACTIVE - INT
数据库记录考试PLE
1 | Test Category | ["1","2"] | 1
2 | Another One | ["1","2","3"] | 1
现在我想创建查询以获得类是有效= 1和类型是阵列(从类型列)。
例如我喜欢的类型是和查询应该看看,如果存在[ “1”, “2”, “3”]
$categories = Db::table('categories')
->where('types', '3') <- ??
->where('active', 1)
->get();
我该怎么办呢?
您正在寻找['FIND_IN_SET()'](http://dev.mysql.com/doc/refman/5.7/en/string-functions.html#function_find-in-set)。不知道OctoberCMS,但我的猜测是它会类似于http://stackoverflow.com/questions/35594450/find-in-set-in-laravel-example – Sean