ShopsN查询单条数据使用find方法,例如:
/** * 获取商品详情 * @author 王波 * $date 2020-09-03 **/ public function getGoodsDetail() { $where = []; $where[] = ['shelves','=',1]; $where[] = ['approval_status','=',1]; $where[] = ['id','=',$id]; $field = 'id,title,pic_url'; $goods = GoodsModel::field($field) ->where($where) ->find(); if(empty($goods)){ $this->errorMessage = "商品信息错误"; return false; } return $goods; }