From c7252261c08db8ac13da17484664bd6d2df58f42 Mon Sep 17 00:00:00 2001 From: ghost Date: Tue, 28 Dec 2021 21:59:53 +0200 Subject: [PATCH] implement addUser method --- src/application/model/user.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/application/model/user.php b/src/application/model/user.php index bec51af..ab4f3b0 100644 --- a/src/application/model/user.php +++ b/src/application/model/user.php @@ -18,4 +18,22 @@ class ModelUser extends Model { return false; } } + + public function addUser(int $blockId, int $userName) { + + try { + + $query = $this->_db->prepare("INSERT INTO `user` SET `blockId` = ?, + `userName` = ?"); + + $query->execute([$blockId, $userName]); + + $this->_db->lastInsertId(); + + } catch (PDOException $e) { + + trigger_error($e->getMessage()); + return false; + } + } } \ No newline at end of file