From fad7dae4e04ca4e2ee41bf0cbd1d96a8b7a609de Mon Sep 17 00:00:00 2001 From: Thomas Chazot Date: Tue, 10 Jan 2023 14:13:34 +0100 Subject: [PATCH] Changement des triggers par modifs dans gateway --- api-rest/gateways/userGateway.php | 6 ++++++ api-rest/initBdd.php | 3 --- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/api-rest/gateways/userGateway.php b/api-rest/gateways/userGateway.php index 04fc029..1f71579 100644 --- a/api-rest/gateways/userGateway.php +++ b/api-rest/gateways/userGateway.php @@ -128,12 +128,18 @@ class UserGateway{ /// Returning TRUE if the user has been added succesfully, FALSE otherwise public function postUser(string $username, string $password, string $nationality, string $sex, string $dateOfBirth) { $insertUserQuery = "INSERT INTO T_S_USER_USR VALUES (NULL, :username, :password, :nationality, :sex, :dateOfBirth, 0, 0, 0, 1)"; + $getLastIdQuery = "SELECT max(PK_ID) FROM T_S_USER_USR"; $argUser=array('username' => array($username, PDO::PARAM_STR), 'password' => array($password, PDO::PARAM_STR), 'nationality' => array($nationality, PDO::PARAM_STR), 'sex' => array($sex, PDO::PARAM_STR), 'dateOfBirth' => array($dateOfBirth, PDO::PARAM_STR)); $this->connection->execQuery($insertUserQuery, $argUser); + $this->connection->execQuery($getLastIdQuery, array()); + $res=$this->connection->getResults(); + foreach($res as $row){ + $this->putSkinList($row['PK_ID'], 1); + } } /// Brief : Modifying an EXISTING user in database diff --git a/api-rest/initBdd.php b/api-rest/initBdd.php index 2fb3b6f..c34c900 100644 --- a/api-rest/initBdd.php +++ b/api-rest/initBdd.php @@ -84,9 +84,6 @@ $conn->query("CREATE TABLE `T_S_USER_USR` ( );"); -$conn->query("CREATE TRIGGER `after_insert_user` AFTER INSERT ON `T_S_USER_USR` FOR EACH ROW INSERT INTO T_J_OWN_SKIN_OWN VALUES(NEW.PK_ID,1); END;"); - - $conn->query("ALTER TABLE `T_E_GAME_GAM` ADD PRIMARY KEY (`PK_ID`), ADD UNIQUE KEY `GAM_NAME` (`GAM_NAME`);");