账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    yii2 使用hasMay关联查询的问题
    30
    0
     $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关联了多个表但是查询的json数据中只有order表的数据

    之前在视图中如果想查询出关联数据 就使用结果集再次调用就行了 例如:$orders->user->email;
    但是现在是api形式的 要如何处理呢?

    0
    打赏
    收藏
    点击回答
        全部回答
    • 共 0 条
    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部