为了账号安全,请及时绑定邮箱和手机立即绑定

TP5 field() 方法 字段不显示

TP5 field() 方法 字段不显示

PHP
蝴蝶不菲 2019-03-11 15:39:19
TP5 模型用field() 方法查询 有一个字段不显示 商品表 模型 /** * 定义商品和商品评论表之间得关系 * * @return \think\model\relation\HasMany */ public function goodsComment() { return $this->hasMany('MallComment', 'goods_id', 'id')->field('user_id,comment,comment_type,create_time'); } 控制器使用 $goodsInfo = Goods::goodsInfo($data['goods_id']); $goodsInfo->goodsComment()->order('create_time desc')->limit(0, 1)->select(); 返回结果 "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" } } ] 返回结果中并没有create_time字段 并且 limit 和 order方法都失效了 数据库里是存在值得 请大神指教下
查看完整描述

1 回答

?
梦里花落0921

TA贡献1772条经验 获得超6个赞

继承父模型隐藏create_time

查看完整回答
反对 回复 2019-03-18
  • 1 回答
  • 0 关注
  • 1875 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信