-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Suite à la demande du product owner, le logo a été changé
- Loading branch information
Showing
5 changed files
with
75 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
|
||
class Database { | ||
private $connector; | ||
private $connection; | ||
|
||
public function __construct(){ | ||
try { | ||
$conn = new PDO("mysql:host=localhost;dbname=db_unesco", $_GET["mail"], $_GET["password"]); | ||
// set the PDO error mode to exception | ||
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | ||
echo "Connected successfully"; | ||
} catch(PDOException $e) { | ||
dir ("Connection failed: " . $e->getMessage()); | ||
} | ||
} | ||
|
||
private function querySimpleExecute($query){ | ||
$req = $this->connector->query($query); | ||
return $req; | ||
} | ||
|
||
public function getOneUnescoSite($site_id) { | ||
$query = "SELECT * FROM t_site_unesco WHERE id_site_unesco=" . $site_id . ";"; | ||
$req = $this->querySimpleExecute($query); | ||
$datas = $req->fetchALL(PDO::FETCH_ASSOC); | ||
return $datas; | ||
} | ||
|
||
public function getAllUnescoSite() { | ||
$query = "SELECT * FROM t_site_unesco"; | ||
$req = $this->querySimpleExecute($query); | ||
$datas = $req->fetchALL(PDO::FETCH_ASSOC); | ||
return $datas; | ||
} | ||
|
||
public function getAllUser() { | ||
$query = "SELECT * FROM t_user"; | ||
$req = $this->querySimpleExecute($query); | ||
$datas = $req->fetchALL(PDO::FETCH_ASSOC); | ||
return $datas; | ||
} | ||
|
||
public function getOneUser($user_name) { | ||
$query = "SELECT * FROM t_user WHERE t_user.name=" . $user_name . ";"; | ||
$req = $this->querySimpleExecute($query); | ||
$datas = $req->fetchALL(PDO::FETCH_ASSOC); | ||
return $datas; | ||
} | ||
|
||
public function getUserHistory($user_id) { | ||
$query = "SELECT * FROM t_history WHERE fk_user=" . $user_id . ";"; | ||
$req = $this->querySimpleExecute($query); | ||
$datas = $req->fetchALL(PDO::FETCH_ASSOC); | ||
return $datas; | ||
} | ||
|
||
public function insertUser($username, $password) { | ||
$query = "INSERT INTO t_user(username, password) VALUES (" . $username . ", " . $password . ");"; | ||
$req = $this->querySimpleExecute($query); | ||
$datas = $req->fetchALL(PDO::FETCH_ASSOC); | ||
return $datas; | ||
} | ||
|
||
public function deleteUser($user_id) { | ||
$query = "DELETE FROM t_user WHERE user_id=" . $user_id . ";"; | ||
$req = $this->querySimpleExecute($query); | ||
$datas = $req->fetchALL(PDO::FETCH_ASSOC); | ||
} | ||
} | ||
// header("Location: ../../index.php"); | ||
?> |