public function index() { $ename = $_GET['ename']; $condition['ename'] = $_GET['ename']; $condition['status'] = 1; $cl = M('columns')->where($condition)->select(); if (!$cl) { $this->error('页面不存在,3秒后跳转到首页', U('/')); } else { $id = $cl[0]['id']; import('Class.Category', APP_PATH); import('ORG.Util.Page'); $columns = M('columns')->order('sort')->select(); $cids = Category::getChildsID($columns, $id); $this->parent = Category::getParents($columns, $id); $cids[] = $id; $where = array('cid' => array('IN', $cids)); $count = M('article')->where($where)->count(); $page = new Page($count, 1); $limit = $page->firstRow . ',' . $page->listRows; $this->article = D("ArtView")->getAll($where, $limit); $this->cl = $cl; $this->page = $page->show(); $this->display(); } }
public function Index() { $id = $_GET['id']; $field = array('id', 'name', 'pid'); $cate = M('cate')->field($field)->order('sort')->select(); import('Class.Category', APP_PATH); $this->parentIds = Category::getParents($cate, $id); $where = array('id' => $id); $this->blog = M('blog')->where($where)->find(); // p($blog); $this->display(); }
public function index() { $id = (int) $_GET['id']; //setInc指定字段加1 setDec指定字段减1 setInc('click',2)增2 M('blog')->where(array('id' => $id))->setInc('click'); $where = array('id' => $id); $field = array('id', 'title', 'time', 'click', 'content', 'cid'); $this->blog = M('blog')->field($field)->find($where); $cid = $this->blog['cid']; import('Class.Category', APP_PATH); $cate = M('cate')->order('sort')->select(); $this->parent = Category::getParents($cate, $cid); $this->display(); }
public function index() { if (!IS_GET) { halt('页面错误'); } $id = (int) $_GET['id']; $field = array('title', 'time', 'id', 'content', 'cid', 'keywords', 'summary'); $article = M('article')->field($field)->find($id); if (!$article) { $this->error('页面不存在,3秒后跳转到首页', U('/')); } else { $this->article = $article; $cid = $this->article['cid']; $column = M('columns')->order('sort')->select(); import('Class.Category', APP_PATH); $this->parent = Category::getParents($column, $cid); $this->display(); } }
function getCategoryParents() { $session = Session::singletone(); $db = Database::singletone()->db(); $cid = Utils::pg("cid", 0); $this->_query->appendChild($this->_dom->createElement("category-id", $cid)); if ($cid <= 0) { $this->error("bad-arguments"); return; } $category = new Category($cid); $parents = $category->getParents(); foreach ($parents as $parent) { $this->_response->appendChild($this->_dom->createElement('parent', $parent)); } $this->success(); }
function getParents() { $parents = array(); if ($this->dbdata('category_parent', 0) > 0) { $parent = new Category($this->dbdata('category_parent')); $parents = $parent->getParents(); $parents[] = $this->dbdata('category_parent'); } return $parents; }