From 44e0d1df1b192eb0bd3ef23d5f04444f556a201d Mon Sep 17 00:00:00 2001 From: brongniart Date: Wed, 9 Oct 2024 17:07:10 +0200 Subject: [PATCH] =?UTF-8?q?Connection=20a=20la=20base=20de=20donn=C3=A9=20?= =?UTF-8?q?r=C3=A9usite(en=20dur=20dans=20le=20code=20pour=20l'instant)+?= =?UTF-8?q?=20insertion=20et=20supr=C3=A9tion=20Users=2050%=20avec=20Kevin?= =?UTF-8?q?=20+=20d=C3=A9but=20Gateway=20pour=20la=20recherche(pas=20teste?= =?UTF-8?q?r)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/profil.php | 2 +- script/user.php | 2 ++ script/userGateway.php | 36 +++++++++++++++++++++++++----------- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/pages/profil.php b/pages/profil.php index 4db7069..e71c703 100644 --- a/pages/profil.php +++ b/pages/profil.php @@ -34,7 +34,7 @@ echo "

{$u->username}

"; echo "

{$u->email}

"; - $passwdhiden = hidenPassWd($u); + $passwdhiden = $u->hidenPassWd($u); echo "

{$passwdhiden}

"; ?> diff --git a/script/user.php b/script/user.php index a2adc20..fcee21b 100644 --- a/script/user.php +++ b/script/user.php @@ -1,9 +1,11 @@ username = $pseudo; diff --git a/script/userGateway.php b/script/userGateway.php index 6aa1478..08b8f37 100644 --- a/script/userGateway.php +++ b/script/userGateway.php @@ -9,22 +9,36 @@ Class UserGateway{ $this->con=$con; } - public function insert(USer $u):int{ + public function insert(User $u):int{ // récupération id - $query='SELECT id_user FROM Users WHERE id_user >= ALL (SELECT id_user FROM User);'; + $query='SELECT id_user FROM Users WHERE id_user >= ALL (SELECT id_user FROM Users);'; $this->con->executeQuery($query); $result=$this->con->getResults(); - $id=$result['id_user'] + 1; - - // insertion user - $query='INSERT INTO Users VALUES (id=:id,username=:username,email=:email,passwd=:passwd,CURRENT_DATE);'; + foreach($result as $row){ + $id=$row['id_user'] + 1; + } + // insertion user + $query='INSERT INTO Users VALUES (:id,:username,:email,:passwd,CURRENT_DATE,false);'; $this->con->executeQuery($query,array(':id' => array($id,PDO::PARAM_INT),':username' => array($u->username,PDO::PARAM_STR),':email' => array($u->email,PDO::PARAM_STR),':passwd' => array($u->passwd,PDO::PARAM_STR))); - return $this->con->lastInsertId(); + return $id; + } + + public function delete(int $id){ + + // supretion user + $query='DELETE FROM Users WHERE id_user = :id;'; + $this->con->executeQuery($query,array(':id' => array($id,PDO::PARAM_INT))); + } + + public function searchQuote(string $quote,int $numpage)//: + { + $query="Select * From Quote Where content LIKE '%:quote%' Limit 20 OFFSET :page*20;"; + $this->con->executeQuery($query,array(':quote' => array($quote,PDO::PARAM_STR),':page' => array($numpage,PDO::PARAM_INT))); + //return ; } -} -$u = new User("Test","1234","none","test@gmail.com"); -$uG = new UserGateway(new Connection("mysql:host=localhost;dbname=dbkemondejar","","")); -$uG->insert($u); +} +$uG = new UserGateway(new Connection("pgsql:host=londres;dbname=dbkekentin","kekentin","")); +$uG->delete(2); ?> \ No newline at end of file