Advertisement
jesse_klaver

loginManager.php

May 29th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.11 KB | None | 0 0
  1. <?php
  2.     require_once 'masterManagers.php';
  3.  
  4.     class loginManagers extends masterManagers {
  5.         function getLogin($aUser) {
  6.             $statement = $this->con->prepare("SELECT * FROM login WHERE username = ? AND password = ?");
  7.             $statement->bindValue(1, $aUser->username); $statement->bindValue(2, $aUser->password);
  8.             $statement->execute(); return $statement->fetch(PDO::FETCH_OBJ);
  9.         }
  10.  
  11.         function newUser($aUser) {
  12.             $statement = $this->con->prepare("INSERT INTO login(username, password, rank) VALUES(?,?,?)");
  13.             $statement->bindValue(1, $aUser->username); $statement->bindValue(2, $aUser->password);
  14.             $statement->bindValue(3, $aUser->rank); $statement->execute();
  15.         }
  16.  
  17.         function getUserById($aId) {
  18.             $statement = $this->con->prepare("SELECT * FROM login WHERE id = ?");
  19.             $statement->bindValue(1, $aId);
  20.             $statement->execute();
  21.             return $statement->fetchColumn(PDO::FETCH_OBJ);
  22.         }
  23.  
  24.         function getIdRank($aUser){
  25.             $statement = $this->con->prepare("SELECT id, rank FROM login WHERE username = ?");
  26.             $statement->bindValue(1, $aUser->username); $statement->execute();
  27.             return $statement->fetch(PDO::FETCH_NUM);
  28.         }
  29.  
  30.         function getAll() {
  31.             $statement = $this->con->prepare("SELECT * FROM login");
  32.             $statement->execute();
  33.             return $statement->fetchAll(PDO::FETCH_OBJ);
  34.         }
  35.  
  36.         function delUser($aId) {
  37.             $statement = $this->con->prepare("DELETE FROM login WHERE id = ?");
  38.             $statement->bindValue(1, $aId); $statement->execute();
  39.             header("Location: ../index.php");
  40.         }
  41.  
  42.         function editUser($aUser) {
  43.             $statement = $this->con->prepare("UPDATE login SET username = ? AND password = ? WHERE id = ?");
  44.             $statement->bindValue(1, $aUser->username); $statement->bindValue(2, $aUser->password);
  45.             $statement->bindValue(3, $aUser->id); $statement->execute();
  46.             header("Location: ../index.php");
  47.         }
  48.     }
  49. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement