dggzichahu/application/common/model/Goods.php

50 lines
1.3 KiB
PHP
Executable File

<?php
// +----------------------------------------------------------------------
// | 宏驰云科技开发团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | Author: HcyShop-kiki
// +----------------------------------------------------------------------
namespace app\common\model;
use think\Db;
use think\Model;
class Goods extends Model
{
/**
* Desc: 获取以规格id为键的商品信息
* @param string $field
* @return array
*/
public static function getColumnGoods($field = '*')
{
$info = Db::name('goods_item i')
->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;
}
}