Dao.php
2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
/**
* 商品图片
* @author tongdesheng
*
*/
use YHMProduct\SqlMap\Goodsimages;
class YHMProduct_Models_Goodsimages_Dao extends YHMProduct_Dao
{
private $_tag = 'yhm_goods_images_';
public function __construct()
{
$this->router = 'goods.yhm_shops';
}
/**
* 通过skc获取所有商品图片
* @param integer $product_skc
*/
public function getByProductSkc($product_skc)
{
return $this->dao()->tag($this->_tag . $product_skc)->key('getByProductSkc')->fetchAll(Goodsimages\Goodsimages::SELECT_IMAGES_BY_SKC, array('product_skc' => $product_skc));
}
/**
* 通过skc获取默认展示图片
* @param int $product_skc
*/
public function getDefaultImageBySkc($product_skc)
{
return $this->dao()->tag($this->_tag . $product_skc)->key('getDefaultImageBySkc')->fetchOne(Goodsimages\Goodsimages::SELECT_DEFAULT_IMAGES_BY_SKC, array('product_skc' => $product_skc));
}
/**
* 通过skc获取一个
* @param $product_skc
* @param $size
* @return Array
*/
public function getOneImagesBySkc($product_skc)
{
return $this->dao()->tag($this->_tag . $product_skc)->fetchOne(Goodsimages\Goodsimages::SELECT_ONE_IMAGES, array(
'product_skc' => $product_skc,
'size' => 1
));
}
/**
* 获取最新的一张图片,用于没有默认图时
* @param int $product_skc
* @return type
*/
public function getOneImageBySkc($product_skc)
{
return $this->dao()->tag($this->_tag . $product_skc)->key('getOneImageBySkc')->fetchOne(Goodsimages\Goodsimages::SELECT_ONE_IMAGES_BY_SKC, array('product_skc' => $product_skc));
}
/**
* 添加商品图片
* @param intger $product_skc
* @param string $image_path
* @param enum $is_default
*/
public function setGoodsImage($product_skc, $image_path, $is_default)
{
return $this->dao()->tag($this->_tag . $product_skc)->insert(Goodsimages\Goodsimages::INSERT_IMAGES, array(
'product_skc' => $product_skc,
'image_path' => $image_path,
'is_default' => $is_default
));
}
/**
* 删除指定skc下所有图片
* @param integer $product_skc
*/
public function delByProductSkc($product_skc)
{
return $this->dao()->tag($this->_tag . $product_skc)->delete(Goodsimages\Goodsimages::DELETE_IMAGES_BY_SKC, array(
'product_skc' => $product_skc
));
}
}