join('goods g', 'g.id = i.goods_id') ->column($field, 'i.id'); return $info; } /** * Desc: 通过规格id获取商品信息 * @param $item_id * @param string $field * @return array|\PDOStatement|string|Model|null * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public static function getOneByItem($item_id, $field = '*') { $info = Db::name('goods_item i') ->field($field) ->join('goods g', 'g.id = i.goods_id') ->where('i.id', $item_id) ->find(); return $info; } }