$order = Orders::find()
->where(['order_sn' => $order_sn, 'user_id' => Yii::$app->user->identity->id])
->all();
{
"success": true,
"code": 200,
"message": "OK",
"data": [
{
"id": "658",
"order_sn": "201811088879168432",
"user_id": "290",
"order_status": 15,
"shipping_id": 0,
"shipping_name": "",
"pay_id": 0,
"pay_name": "",
"goods_amount": "1067.00",
"user_discount": 100,
"shipping_fee": "0.00",
"pay_fee": "0.00",
"integral_money": "0.00",
"coupon_id": "0",
"coupon": "0.00",
"order_amount": "1067.00",
"created_at": "1541658432",
"pay_time": "0",
"shipping_time": "0",
"finish_time": "0",
"shipping_no": "",
"pay_note": "",
"ip_address": "127.0.0.1",
"region_id": 12,
"coupon_code_id": null,
"discount_amount": null
}
]
}
ordes關(guān)聯(lián)了多個(gè)表但是查詢(xún)的json數(shù)據(jù)中只有order表的數(shù)據(jù)
之前在視圖中如果想查詢(xún)出關(guān)聯(lián)數(shù)據(jù) 就使用結(jié)果集再次調(diào)用就行了 例如:$orders->user->email;但是現(xiàn)在是api形式的 要如何處理呢?
yii2 使用hasMay關(guān)聯(lián)查詢(xún)的問(wèn)題
慕工程0101907
2019-03-06 23:52:19