id = $rs['id']; $this->username = $rs['username']; $this->email = $rs['email']; $this->permission = $rs['permission']; } else { // Method 2 通过用户 ID 查找用户 $rs = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM `{$db['name']}`.`users` WHERE `id`='{$username}'")); if($rs) { $this->id = $rs['id']; $this->username = $rs['username']; $this->email = $rs['email']; $this->permission = $rs['permission']; } else { // Method 3 通过用户邮箱查找用户 $rs = mysqli_fetch_array(mysqli_query($conn, "SELECT * FROM `{$db['name']}`.`users` WHERE `email`='{$username}'")); if($rs) { $this->id = $rs['id']; $this->username = $rs['username']; $this->email = $rs['email']; $this->permission = $rs['permission']; } else { // 未找到任何数据,返回 null $this->id = null; $this->username = null; $this->email = null; $this->permission = null; } } } } } }