/** * Add user to the database. * * @param \model\User $user The user to be added to the database */ public function add(User $user) { $sqli = $this->database->connect(); $stmt = $sqli->prepare("INSERT INTO `users`(`username`, `password`) VALUES (?, ?)"); if ($stmt === FALSE) { throw new Exception($sqli->error); } $username = $user->getUsername(); $password = $user->getPassword(); $stmt->bind_param('ss', $username, $password); $stmt->execute(); }
/** * Update user information * @param String $username The user that will be updated. * @param String $info String in JSON-format to be stored in the database. */ public function updateUser($username, $info) { $sqli = $this->database->connect(); $stmt = $sqli->prepare("UPDATE " . $this->table . " SET " . $this->profileinfoCol . "='" . $info . "' WHERE " . $this->usernameCol . "='" . $username . "'"); if ($stmt === FALSE) { throw new Exception($sqli->error); } $stmt->execute(); }