コード例 #1
0
 public function index()
 {
     $ac_id = I('cate', 0, 'int');
     $pid = M('ArticleClass')->where(array('ac_id' => $ac_id))->getField('ac_parent_id');
     if ($pid) {
         $this->ac_list = M('ArticleClass')->where(array('ac_parent_id' => $pid))->order('ac_sort desc')->select();
     } else {
         $this->ac_list = M('ArticleClass')->where(array('ac_parent_id' => $ac_id))->order('ac_sort desc')->select();
     }
     $ac_list = M('ArticleClass')->order('ac_sort desc')->select();
     $ac_list = getChildsId($ac_list, $ac_id, 'ac_id', 'ac_parent_id');
     if (is_array($ac_list)) {
         $ac_list_str = $ac_id . ',';
         foreach ($ac_list as $key => $val) {
             $ac_list_str .= $val . ',';
         }
         $ac_list_str = substr($ac_list_str, 0, -1);
     }
     $where['ac_id'] = array('IN', $ac_list_str);
     $where['article_show'] = 1;
     $count = $this->model->where($where)->count();
     $page = new Page($count, 10);
     $list = $this->model->where($where)->limit($page->firstRow . ',' . $page->listRows)->order('article_sort desc,article_time desc')->select();
     $this->list = $list;
     $this->page = $page->show();
     $this->display();
 }
コード例 #2
0
 public function index()
 {
     $search = $_GET;
     $gc = array();
     if (intval($search['cate'])) {
         $array = M('GoodsClass')->order('gc_sort desc')->select();
         $ids = getChildsId($array, intval($search['cate']), 'gc_id', 'gc_parent_id');
         $ids[] = intval($search['cate']);
         $where['gc_id'] = array('IN', $ids);
         $gc = M('GoodsClass')->where($where)->find();
         if ($gc['gc_parent_id']) {
             $pcate = $gc['gc_parent_id'];
         } else {
             $pcate = intval($search['cate']);
         }
         $search['cateName'] = $gc['gc_name'];
         $param['title'] = $gc['gc_title'];
         $param['keywords'] = $gc['gc_key'];
         $param['description'] = $gc['gc_desc'];
         $this->seo = seo($param);
     }
     if (trim($search['tag'])) {
         $tag = explode(',', trim($search['tag']));
         $where['_string'] = '';
         if (is_array($tag)) {
             foreach ($tag as $key => $val) {
                 $where['_string'] .= '(tag like "%|' . $val . '|%") AND ';
             }
             $where['_string'] = substr($where['_string'], 0, -5);
         }
     }
     $order = 'goods_sort desc';
     $where['goods_status'] = 1;
     $count = D('Goods')->where($where)->count();
     $page = new Page($count, 8);
     $list = D('Goods')->where($where)->limit($page->firstRow . ',' . $page->listRows)->order($order)->select();
     $tc_ids = $gc['tc_id'];
     if (!empty($tc_ids)) {
         $tag_class = D('TagClass')->relation(true)->where(array('tc_id' => array('IN', $tc_ids)))->order('tc_sort desc')->select();
         $this->assign('tag_class', $tag_class);
     }
     $this->assign('pcate', $pcate);
     $this->assign('list', $list);
     $this->assign('page', $page->show());
     $this->assign('search', $search);
     $this->display();
 }
コード例 #3
0
ファイル: function.php プロジェクト: noikiy/sryy
/**
 * 获取子级ID
 * @param array $array 集合数组
 * @param int $pid 父级ID
 * @param string $idKey 索引键名
 * @param string $pidKey 父级关联键名
 * @return Ambigous <multitype:, multitype:unknown >
 */
function getChildsId($array, $pid, $idKey, $pidKey)
{
    $arr = array();
    foreach ($array as $v) {
        if ($v[$pidKey] == $pid) {
            $arr[] = $v[$idKey];
            $arr = array_merge($arr, getChildsId($array, $v[$idKey], $idKey, $pidKey));
        }
    }
    return $arr;
}
コード例 #4
0
 public function delBreakdown()
 {
     $bd_id = intval($_GET['bd_id']);
     $array = M('Breakdown')->select();
     $ids = getChildsId($array, $bd_id, 'bd_id', 'bd_upid');
     if (is_array($ids) && !empty($ids)) {
         $this->error('请先删除子级分类');
     }
     $res = M('Breakdown')->where(array('bd_id' => $bd_id))->delete();
     if ($res) {
         $this->success('删除成功.');
     } else {
         $this->error('删除失败');
     }
 }