Commit 9700c873 authored by zhz's avatar zhz

goods

parent b5709341
...@@ -67,6 +67,9 @@ class GoodsCommonModel extends \DAO\AbstractModel { ...@@ -67,6 +67,9 @@ class GoodsCommonModel extends \DAO\AbstractModel {
*/ */
public function getGoodsList($where,$field,$limit=array(),$order=array(),$attrStr=''){ public function getGoodsList($where,$field,$limit=array(),$order=array(),$attrStr=''){
$this->setDb($this->dbName); $this->setDb($this->dbName);
if($attrStr) {
$field .= 'DISTINCT '.$field;
}
$str = '$data = $this->db->select($field)->from($this->_tableName)'; $str = '$data = $this->db->select($field)->from($this->_tableName)';
if($attrStr){ if($attrStr){
$str .="->join('han_goods_attribute_value','han_goods_attribute_value.goods_commonid = han_goods_common.goods_commonid')"; $str .="->join('han_goods_attribute_value','han_goods_attribute_value.goods_commonid = han_goods_common.goods_commonid')";
...@@ -86,7 +89,6 @@ class GoodsCommonModel extends \DAO\AbstractModel { ...@@ -86,7 +89,6 @@ class GoodsCommonModel extends \DAO\AbstractModel {
} }
$str .= "->fetchAll();"; $str .= "->fetchAll();";
eval($str); eval($str);
\Our\Log::getInstance()->write($this->db->getLastSql());
return $data; return $data;
} }
/** /**
...@@ -100,6 +102,9 @@ class GoodsCommonModel extends \DAO\AbstractModel { ...@@ -100,6 +102,9 @@ class GoodsCommonModel extends \DAO\AbstractModel {
*/ */
public function getListWithSale($where,$field,$actIds,$limit=array(),$order=array(),$attrStr='',$online = true){ public function getListWithSale($where,$field,$actIds,$limit=array(),$order=array(),$attrStr='',$online = true){
$this->setDb($this->dbName); $this->setDb($this->dbName);
if($attrStr) {
$field .= 'DISTINCT '.$field;
}
$str = "select ".$field." FROM ".$this->_tableName." LEFT JOIN (SELECT MIN(discount_price) discount_price,goods_commonid,goods_id FROM han_sale_goods where sale_act_id in(".implode(',',$actIds).") GROUP BY goods_commonid) a on (han_goods_common.goods_commonid = a.goods_commonid)"; $str = "select ".$field." FROM ".$this->_tableName." LEFT JOIN (SELECT MIN(discount_price) discount_price,goods_commonid,goods_id FROM han_sale_goods where sale_act_id in(".implode(',',$actIds).") GROUP BY goods_commonid) a on (han_goods_common.goods_commonid = a.goods_commonid)";
if($attrStr){ if($attrStr){
$str .= "INNER JOIN han_goods_attribute_value ON han_goods_attribute_value.goods_commonid = han_goods_common.goods_commonid "; $str .= "INNER JOIN han_goods_attribute_value ON han_goods_attribute_value.goods_commonid = han_goods_common.goods_commonid ";
...@@ -125,7 +130,6 @@ class GoodsCommonModel extends \DAO\AbstractModel { ...@@ -125,7 +130,6 @@ class GoodsCommonModel extends \DAO\AbstractModel {
$str .=" limit {$limit[0]},{$limit[1]}"; $str .=" limit {$limit[0]},{$limit[1]}";
} }
$data = $this->db->query($str); $data = $this->db->query($str);
\Our\Log::getInstance()->write($this->db->getLastSql());
return $data->rows; return $data->rows;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment