TP5 field () method fields are not displayed

TP5 model queries with the field () method have a field that does not display

Commodity table model

/**
     * 
     *
     * @return \think\model\relation\HasMany
     */
    public function goodsComment() {
        return $this->hasMany("MallComment", "goods_id", "id")->field("user_id,comment,comment_type,create_time");
    }

Controller uses

        $goodsInfo = Goods::goodsInfo($data["goods_id"]);
        $goodsInfo->goodsComment()->order("create_time desc")->limit(0, 1)->select();

return the result

   "goodsComment": [
            {
                "user_id": 33,
                "comment": "",
                "comment_type": 2,
                "user": {
                    "nickname": "XX",
                    "photo": "9f1cd8fd29d4b17ccd93b333ff558118.png"
                }
            },
            {
                "user_id": 33,
                "comment": "",
                "comment_type": 1,
                "user": {
                    "nickname": "XX",
                    "photo": "9f1cd8fd29d4b17ccd93b333ff558118.png"
                }
            }
        ]

there is no create_time field in the returned result, and both the limit and order methods are invalidated. There is a worthy existence in the database

.

clipboard.png

ask the great god for advice

Mar.24,2021

inherit the parent model to hide create_time

Menu