serviceManager = $serviceManager; $this->init(); return $this; } private function init () { $dbService = $this->serviceManager->get('Db'); $this->db = $dbService->getPdo(); } /** * 所有用户 * @param $usertype * @return mixed */ public function fetchAll ($usertype) { $sql = "SELECT * FROM users WHERE usertype = '$usertype'"; $rs = $this->db->query($sql); return $rs->fetchAll(\PDO::FETCH_ASSOC); } /** * 用户详细信息 * @param $userid * @return mixed */ public function view ($userid) { $sql = "SELECT * FROM users WHERE id = $userid"; $rs = $this->db->query($sql); return $rs->fetchAll(\PDO::FETCH_ASSOC); } /** * 禁止用户 * @param $userid * @return mixed */ public function ban ($userid, $status) { $sql = "UPDATE users SET status= $status WHERE id = $userid"; $this->db->exec($sql); return true; } /** * 黑河用户 * @return bool */ public function fetchAllHeiHe () { $sql = "SELECT * FROM heiheuser ORDER BY id DESC"; $rs = $this->db->query($sql); return $rs->fetchAll(\PDO::FETCH_ASSOC); return true; } /** * 所有长时间未登录的用户 * @return mixed */ public function fetchAllSendmail () { $time = date("Y-m-d H:i:s", time()-3 * 365 * 24 * 3600); $sql = "SELECT * FROM users WHERE ts_last_login<'$time' ORDER BY ts_last_login DESC"; $rs = $this->db->query($sql); return $rs->fetchAll(\PDO::FETCH_ASSOC); } }