【发布时间】:2019-04-25 20:15:20
【问题描述】:
我有 2 个模型 篮子和产品 我的产品表有 json 对象列,我写这样的代码
$basket=Basket::with("product")->whereJsonContains("product->store->id",$stores_id)->get();
但是 laravel 不返回数据给我。 抛出这个错误
SQLSTATE[42S22]:未找到列:1054 中的未知列“产品” 'where 子句' (SQL: select * from
shopping_cardswhere json_contains(product->'$.\"store\".\"id\"', 39))
我的数据结构是这样的
{
"id": 3,
"users_id": 1,
"quantity": 1,
"product": {
"id": 116,
"store": {
"id": 39,
"status": 41,
}
}
}
【问题讨论】:
标签: php mysql laravel-5 orm eloquent