-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserManager.php
More file actions
50 lines (40 loc) · 895 Bytes
/
UserManager.php
File metadata and controls
50 lines (40 loc) · 895 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
require_once 'debugSettings.php';
require_once '../dbinfo/dbcred.php';
//require_once('User.php');
/**
*
*/
class UserManager
{
private $db;
function __construct()
{
$this->db = $this->dbConnect();
}
private function dbConnect() {
try {
$db = new PDO('mysql:host=localhost;dbname='.DB_NAME, DB_USERNAME, DB_PASSWORD);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
return $db;
} catch (PDOException $e) {
//echo $e->getMessage();
return $e->getMessage();
}
}
public function getUserByEmail($email){
$email = $this->db->quote($email);
$sql = "SELECT userID, name, role, email FROM `users` WHERE `email`=" . $email;
try {
$result = $this->db->query($sql);
$data = $result->fetch(PDO::FETCH_ASSOC);
if($data){
return $data;
}
return false;
} catch (PDOExcption $e){
return $e->getMessage();
}
}
}
?>