public function sechWeibo() { if (!IS_POST) { E('页面不存在'); } $keyWord = htmlspecialchars($_POST['keyword']); $where = array('content' => array('LIKE', '%' . $keyWord . '%')); //分页 $count = M('weibo')->where($where)->count(); $page = format_fenye($count, C('PAGE_SIZE_HOME')); $limit = $page->firstRow . ',' . $page->listRows; $weibo = D('WeiboView')->where($where)->limit($limit)->order('time DESC')->select(); $this->weibo = $weibo; $this->page = $page->show(); $this->keyword = $keyWord; $this->display(); }
/** * 首页数据展现:用户和用户关注的人发送微博;以及分组的微博 */ public function index() { //得到用户所有的关注列表 $gid = $_GET['gid']; $me = session('uid'); $where = isset($gid) ? array('gid' => intval($gid), 'fans' => $me) : array('fans' => $me); //区分是全部还是分组信息 $follows = M('follow')->where($where)->select(); $my_follow_str = $me; //遍历用户的关注数组 foreach ($follows as $k => $v) { $my_follow_str .= ',' . $v['follow']; } $where = array('uid' => array('in', $my_follow_str)); //得到分页信息 $count = M('weibo')->where($where)->count(); $page = format_fenye($count, C('PAGE_SIZE_HOME')); $limit = $page->firstRow . ',' . $page->listRows; $db = D('WeiboView'); //得到微博列表 $weibo = $db->where($where)->limit($limit)->order('time DESC')->select(); //区分是否转发微博 foreach ($weibo as $k => $v) { $turnId = $v['isturn']; if ($turnId) { $turnWeibo = $db->where(array('id' => $turnId))->find(); //isturn 的id替换成转发的微博数据 $v['isturn'] = $turnWeibo; $weibo[$k] = $v; } } //分配数据 $this->weibo = empty($weibo) ? fasle : $weibo; $this->page = $page->show(); $this->display(); }
public function showAtMe() { $me = session('uid'); //分页 $where = array('uid' => $me); $count = M('atme')->where($where)->count(); $page = format_fenye($count, C('PAGE_SIZE_HOME')); $limit = $page->firstRow . ',' . $page->listRows; $weibo = D('AtmeView')->where($where)->order('time')->limit($limit)->select(); $this->atme = true; $this->weibo = empty($weibo) ? false : $weibo; $this->page = $page->show(); $this->display('weiboList'); }