/** * 获取统计 * @param int $id 用户ID * @param int $flag_id 是否为收信箱或发信箱类型,为1为发信箱,2为收信箱,3为系统信息 * @return bool 是否能获取到当前页面 */ private function getCountInfo($id, $flag_id) { $count = 0; switch ($flag_id) { case 1: //排除已经删除的信息 $count = $this->db->count("message", ['AND' => ['from_users_id' => $id, 'from_del' => 0]]); break; case 2: $count = $this->db->count("message", ['AND' => ['to_users_id' => $id, 'to_del' => 0]]); break; case 3: $count = $this->db->count("message", ['from_users_id' => NULL]); break; default: Log::write("\$flag_id={$flag_id} is error. On " . __FILE__ . ":" . __LINE__); $this->throwMsg(-11); } $this->count['count'] = $count; $this->count['max'] = intval(ceil($count / $this->count['number'])); if ($this->count['page'] > $this->count['max']) { $this->count['page'] = -1; return false; } return true; }
/** * @param int $id * @param null|string $type * @return bool */ private function getCountInfo($id, $type = NULL) { $count = 0; switch ($type) { case NULL: $count = $this->db->count("feed", ['users_id' => $id]); break; } $this->count['count'] = $count; $this->count['max'] = intval(ceil($count / $this->count['number'])); if ($this->count['page'] > $this->count['max']) { $this->count['page'] = -1; return false; } return true; }
private function getCountInfo($id = NULL, $type = NULL) { $count = 0; switch ($type) { case 'all': $count = $this->db->count("gallery", ['gallery_status' => 1]); break; case 'user': $count = $this->db->count('gallery', ['AND' => ['users_id' => $id, 'gallery_status' => 1]]); break; } $this->count['count'] = $count; $this->count['max'] = intval(ceil($count / $this->count['number'])); if ($this->count['page'] > $this->count['max']) { $this->count['page'] = -1; return false; } return true; }
/** * @param int $uid 等于0为全部,需权限,-1为公共全部,大于0为用户 * @return bool */ private function getCountInfo($uid) { $count = 0; if ($uid === 0 && User::getUser($uid)->Permission('Control')) { $count = $this->db->count("posts"); } elseif ($uid === -1) { $count = $this->db->count("posts", ['post_status' => 1]); } else { $count = $this->db->count("posts", ['users_id' => $uid]); } $this->count['count'] = $count; $this->count['max'] = intval(ceil($count / $this->count['number'])); if ($this->count['page'] > $this->count['max']) { $this->count['page'] = -1; return false; } return true; }
/** * 设置评论类型的分页信息 * @param int $type * @param int $id * @return bool */ private function setCount($type, $id) { $count = 0; switch ($type) { case self::TYPE_Comment_user: $count = $this->db->count($this->table, ['users_id' => $id]); break; case self::TYPE_Object_user: $count = $this->db->count($this->table, ['object_users_id' => $id]); break; } if ($count < 1) { return false; } else { $this->count['count'] = $count; $this->count['max'] = intval(ceil($count / $this->count['number'])); if ($this->count['page'] > $this->count['max']) { $this->count['page'] = -1; return false; } } return true; }
/** * @param $user_id * @return int */ public function countUserGallery($user_id) { return $this->db->count("gallery", ['users_id' => $user_id]); }