/** * 获得当前id是否有子节点 * * @param unknown_type $mode * @param unknown_type $id * @return boolean */ function getChildren($mode, $id) { $map['pid'] = array('eq', $id); $result = $mode->where($map)->select(); //echo $mode->_sql(); if ($result) { return true; } else { return false; } }
/** * 分页方法 ThinkPHP * * @author Vonwey <*****@*****.**> * @CreateDate: 2013-12-12 上午11:09:19 * @param unknown_type $model * @param unknown_type $pageNum * @param unknown_type $where * @param unknown_type $order */ public function memberPage($model, $where = array(), $pageNum = 10, $order = '') { $_GET['p'] = $_GET['p'] ? $_GET['p'] : 0; // 进行分页数据查询 注意page方法的参数的前面部分是当前的页数使用 $_GET[p]获取 $list = $model->where($where)->order($order)->page($_GET['p'] . ',' . $pageNum)->select(); $this->assign('list', $list); // 赋值数据集 // echo $model->getLastSql(); import("ORG.Util.Page"); // 导入分页类 $count = $model->where($where)->count(); // 查询满足要求的总记录数 $Page = new Page($count, $pageNum); // 实例化分页类 传入总记录数和每页显示的记录数 $Page->setConfig('first', '首页'); $Page->setConfig('last', '尾页'); $Page->setConfig('theme', '共%totalRow% %header% %nowPage%/%totalPage% 页 %first% %upPage% %prePage% %linkPage% %downPage% %end%'); $show = $Page->show(); // 分页显示输出 $this->assign('page', $show); // 赋值分页输出 return $list; }
/** * 获取带where_in条件的数据,并分组 * @param array $cwhere * @param array $where_in */ public function get_group_where_in($cwhere = NULL, $where_in = NULL, $group = NULL) { $this->db->select($this->cols, $this->colsFormat); $this->db->from($this->table); foreach ($this->join as $ajoin) { $this->db->join($ajoin['table'], $ajoin['where'], $ajoin['type']); } if ($cwhere) { $this->db->where($cwhere); } if ($where_in) { $this->db->where_in($where_in['column'], $where_in['$arr']); } $this->initialize(); $this->db->group_by($group); $this->clear(); return $this->db->get(); }
/** * 判断作者 * @param unknown_type $dao * @param unknown_type $field * @param unknown_type $id * @param unknown_type $user * @return boolean */ function CheckAuthorPermission($dao, $id, $field = 'id', $getfield = 'uid') { $map[$field] = $id; $value = $dao->where($map)->getField($getfield); return $value == $GLOBALS['ts']['mid']; }