<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Ordergoods_model extends CI_Model
{
private $table = 'ordergoods';
public function __construct()
{
parent::__construct();
}
public function getGoodsById($orderId = 0)
{
$orderId = intval($orderId);
if(!empty($orderId))
{
$this->db->where('orderId',$orderId);
}
$res = $this->db->get($this->table)->result_array();
return $res;
}
public function orderGoodsCount($orderId = 0)
{
$this->db->select('COUNT(*) as num');
$this->db->where('orderId',$orderId);
$res = $this->db->get($this->table)->row_array();
return !empty($res['num']) ? $res['num'] : 0;
}
public function addOrderGoods($data)
{
$bool = $this->db->insert($this->table, $data);
return $bool;
}
public function orderGoods($goodsId=0, $goodsSku='', $orderId=0, $spec='')
{
if(!empty($goodsId))
{
$this->db->where('goodsId', $goodsId);
}
if(!empty($goodsSku))
{
$this->db->where('goodsSku', $goodsSku);
}
if(!empty($orderId))
{
$this->db->where('orderId', $orderId);
}
if(!empty($spec))
{
$this->db->where('spec', $spec);
}
$res = $this->db->get($this->table)->row_array();
return $res;
}
}