<?php 
class datasource_user {
	function get_ads_position($position) {
		$obj_db = cls_obj::db();
		$arr_return = array();
		$arr_list = array();
		$where = " where ads_position='$position'";
		$obj_result = $obj_db->select("select ads_html from " . cls_config::DB_PRE . "other_ads" . $where . " order by ads_sort asc limit 0,10");
		while($obj_rs = $obj_db->fetch_array($obj_result)) {
			$arr_list[] = $obj_rs;
		}
		$arr_return = $arr_list;
		return $arr_return;
	}
	function get_folder_article($folder_id,$num) {
		$obj_db = cls_obj::db();
		$arr_return = array();
		$arr_list = array();
		$where = " where article_folder_id='$folder_id'";
		$obj_result = $obj_db->select("select article_id,article_title from " . cls_config::DB_PRE . "article" . $where . " limit 0,$num");
		while($obj_rs = $obj_db->fetch_array($obj_result)) {
			$arr_list[] = $obj_rs;
		}
		$arr_return = $arr_list;
		return $arr_return;
	}
	function get_folder_bykey($key) {
		$obj_db = cls_obj::db();
		$arr_return = array();
		$arr_list = array();
		$where = " where folder_key='$key'";
		$obj_result = $obj_db->select("select folder_id,folder_name from " . cls_config::DB_PRE . "article_folder" . $where . "");
		while($obj_rs = $obj_db->fetch_array($obj_result)) {
			$arr_list[] = $obj_rs;
		}
		$arr_return = $arr_list;
		return $arr_return;
	}
	function category_childs($id,$num) {
		$obj_db = cls_obj::db();
		$arr_return = array();
		$arr_list = array();
		$where = " where category_pid='$id'";
		$obj_result = $obj_db->select("select category_id,category_name,category_pic from " . cls_config::DB_PRE . "mall_goods_category" . $where . " order by category_sort asc limit 0,$num");
		while($obj_rs = $obj_db->fetch_array($obj_result)) {
			$arr_list[] = $obj_rs;
		}
		$arr_return = $arr_list;
		return $arr_return;
	}
	function category_goods($id,$num) {
		$obj_db = cls_obj::db();
		$arr_return = array();
		$arr_list = array();
		$where = " where " . $obj_db->concat(",","category_pids",",") . " like '%,$id,%' and goods_state>'0'";
		$obj_result = $obj_db->select("select goods_id,goods_name,goods_price,goods_price_market,goods_pic,goods_pic_small,goods_sold from " . cls_config::DB_PRE . "mall_goods left join " . cls_config::DB_PRE . "mall_goods_category on goods_category_id=category_id" . $where . " order by goods_addtime desc limit 0,$num");
		while($obj_rs = $obj_db->fetch_array($obj_result)) {
			$arr_list[] = $obj_rs;
		}
		$arr_return = $arr_list;
		return $arr_return;
	}
	function get_goods_hot($start,$end) {
		$obj_db = cls_obj::db();
		$arr_return = array();
		$arr_list = array();
		$where = " where goods_state>'0'";
		$obj_result = $obj_db->select("select goods_id,goods_shop_id,goods_name,goods_price,goods_price_market,goods_pic,goods_pic_small,goods_hits,goods_sold from " . cls_config::DB_PRE . "mall_goods" . $where . " order by goods_sold desc limit $start,$end");
		while($obj_rs = $obj_db->fetch_array($obj_result)) {
			$arr_list[] = $obj_rs;
		}
		$arr_return = $arr_list;
		return $arr_return;
	}
	function get_goods_bysold($cid,$start,$end) {
		$obj_db = cls_obj::db();
		$arr_return = array();
		$arr_list = array();
		$where = " where " . $obj_db->concat(",","category_pids",",") . " like '%,$cid,%' and goods_state>'0'";
		$obj_result = $obj_db->select("select goods_id,goods_shop_id,goods_name,goods_store,goods_price,goods_price_market,goods_pic,goods_pic_small,goods_hits,goods_sold from " . cls_config::DB_PRE . "mall_goods left join " . cls_config::DB_PRE . "mall_goods_category on goods_category_id=category_id" . $where . " order by goods_sold desc limit $start,$end");
		while($obj_rs = $obj_db->fetch_array($obj_result)) {
			$arr_list[] = $obj_rs;
		}
		$arr_return = $arr_list;
		return $arr_return;
	}
	function get_goods_bytime($cid,$start,$end) {
		$obj_db = cls_obj::db();
		$arr_return = array();
		$arr_list = array();
		$where = " where " . $obj_db->concat(",","category_pids",",") . " like '%,$cid,%' and goods_state>'0'";
		$obj_result = $obj_db->select("select goods_id,goods_name,goods_store,goods_price,goods_price_market,goods_pic,goods_pic_small,goods_hits,goods_sold from " . cls_config::DB_PRE . "mall_goods left join " . cls_config::DB_PRE . "mall_goods_category on goods_category_id=category_id" . $where . " order by goods_id desc limit $start,$end");
		while($obj_rs = $obj_db->fetch_array($obj_result)) {
			$arr_list[] = $obj_rs;
		}
		$arr_return = $arr_list;
		return $arr_return;
	}
	function get_goods_tj1($start,$end) {
		$obj_db = cls_obj::db();
		$arr_return = array();
		$arr_list = array();
		$where = " where goods_state>'0' and goods_tj1='1'";
		$obj_result = $obj_db->select("select goods_id,goods_shop_id,goods_name,goods_price,goods_price_market,goods_pic,goods_pic_small,goods_sold from " . cls_config::DB_PRE . "mall_goods" . $where . " order by goods_id desc limit $start,$end");
		while($obj_rs = $obj_db->fetch_array($obj_result)) {
			$arr_list[] = $obj_rs;
		}
		$arr_return = $arr_list;
		return $arr_return;
	}
	function get_goods_tj2($cid,$start,$end) {
		$obj_db = cls_obj::db();
		$arr_return = array();
		$arr_list = array();
		$where = " where " . $obj_db->concat(",","category_pids",",") . " like '%,$cid,%' and goods_tj2='1' and goods_state>'0'";
		$obj_result = $obj_db->select("select goods_id,goods_shop_id,goods_name,goods_price,goods_price_vip,goods_price_market,goods_pic,goods_pic_small,goods_hits,goods_sold from " . cls_config::DB_PRE . "mall_goods left join " . cls_config::DB_PRE . "mall_goods_category on goods_category_id=category_id" . $where . " order by goods_id desc limit $start,$end");
		while($obj_rs = $obj_db->fetch_array($obj_result)) {
			$arr_list[] = $obj_rs;
		}
		$arr_return = $arr_list;
		return $arr_return;
	}
}