From 6a422167ecfcef3e8648dac70058d4b976ebee0f Mon Sep 17 00:00:00 2001 From: nathan boileau Date: Fri, 25 Nov 2022 18:49:57 +0100 Subject: [PATCH] bd --- WEB/Config/Config.php | 6 ++--- WEB/Config/Connection.php | 44 +++++++++++++++---------------- WEB/Controller/UserController.php | 9 +++++-- 3 files changed, 32 insertions(+), 27 deletions(-) diff --git a/WEB/Config/Config.php b/WEB/Config/Config.php index 4c748d96..1846fe2d 100644 --- a/WEB/Config/Config.php +++ b/WEB/Config/Config.php @@ -14,9 +14,9 @@ $rep = __DIR__ . '/../'; // $password = 'p'; // SQULITE3 -$dsn = 'sqlite:./Model/scripted.db'; -$user = null; -$password = null; +// $dsn = 'sqlite:./Model/scripted.db'; +// $user = null; +// $password = null; diff --git a/WEB/Config/Connection.php b/WEB/Config/Connection.php index b8784d36..00557d26 100644 --- a/WEB/Config/Connection.php +++ b/WEB/Config/Connection.php @@ -1,26 +1,26 @@ setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } +// class Connection extends PDO { +// private $stmt; +// public function __construct(string $dsn) { +// parent::__construct($dsn); +// echo "connection"; +// $this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } - public function executeQuery(string $query, array $parameters = []) :bool { - $this->stmt = parent::prepare($query); - foreach ($parameters as $name => $value) { - $this->stmt->bindValue($name, $value[0], $value[1]); } - return $this->stmt->execute(); } - public function getResults(): array { - return $this->stmt->fetchall(); - } -} +// public function executeQuery(string $query, array $parameters = []) :bool { +// $this->stmt = parent::prepare($query); +// foreach ($parameters as $name => $value) { +// $this->stmt->bindValue($name, $value[0], $value[1]); } +// return $this->stmt->execute(); } +// public function getResults(): array { +// return $this->stmt->fetchall(); +// } +// } -// class Connection extends SQLite3 -// { -// function __construct() -// { -// $this->open('./Model/sripted.db'); -// } -// } \ No newline at end of file +class Connection extends SQLite3 +{ + function __construct() + { + $this->open('./Model/sripted.db'); + } +} \ No newline at end of file diff --git a/WEB/Controller/UserController.php b/WEB/Controller/UserController.php index c62150b2..8f80c0b1 100644 --- a/WEB/Controller/UserController.php +++ b/WEB/Controller/UserController.php @@ -9,14 +9,19 @@ class UserController function __construct() { global $dsn, $user, $password; - $this->con=new Connection($dsn); + // $this->con=new Connection($dsn); + $this->con=new Connection (); try{ global $rep, $vues, $error; $action=$_REQUEST['action']; echo "userController"; switch($action) { case NULL: - require ($rep.$vues['main']); + $db= new Connection(); + $db->exec('INSERT INTO Utilisateur VALUES ("e","e","e", false)' ); + $res=$db->exec('SELECT * FROM Utilisateur' ); + echo $res; + // require ($rep.$vues['main']); break; case "signUp": $this->signUp();