public function goodsByCate($cateID, $n = null, $start = null) { $cateObj = new CategoryModel(); $allCates = $cateObj->select(); $cateList = $cateObj->getCatTree($allCates, $cateID); $cateIDList = array($cateID); foreach ($cateList as $v) { $cateIDList[] = $v['cat_id']; } $instring = implode(',', $cateIDList); $sql = 'select goods_id,goods_name, shop_price, market_price, thumb_img, add_time, goods_img from ' . $this->table . ' where cat_id in (' . $instring . ') order by add_time desc'; if (is_numeric($n) && is_numeric($start)) { $sql .= ' limit ' . $start . ',' . $n; } $data = $this->db->getAll($sql); return $data; }
/** * 文章编辑页面 */ function edit() { $art_id = $_GET['id']; if (!empty($art_id)) { //获得文章 $art = new ArticleModel(); $list = $art->getById($art_id); $this->assign('alist', $list); //获得单元 $sec = new SectionModel(); $list = $sec->order('id')->select(); $this->assign('slist', $list); //获得分类 $cat = new CategoryModel(); $list = $cat->select(); $this->assign('clist', $list); } $this->display(); }
/* 商品页 */ define('ACC', true); require '../system/init.php'; $cateObj = new CategoryModel(); $goodsObj = new GoodsModel(); $goodsID = $_GET['goods_id']; $goodsInfo = $goodsObj->find($goodsID); if (!isset($goodsInfo)) { header('Location: index.php'); } //print_r(serialize($goodsInfo)); $catID = $goodsInfo['cat_id']; $allCates = $cateObj->select(); $cateNav = $cateObj->getTree($allCates, $catID); $cateInfo = $cateObj->find($catID); //print_r($cateNav); //加入浏览记录用cookie做 //是否有cookie,没有则设置,有则加入,超过5个自动删除 if (isset($_COOKIE['goods_history'])) { $history = _unserialize($_COOKIE['goods_history']); foreach ($history as $k => $v) { if ($v['goods_id'] != $goodsID) { continue; } else { array_splice($history, $k, 1); break; } }