/** * Update one person in database. * * @param integer $id * @param \Entities\Person $person * @return void */ public function update($id, Person $person) { $id = intval($id); $firstname = $this->pdo->quote($person->getFirstname()); $lastname = $this->pdo->quote($person->getLastname()); $this->pdo->exec("UPDATE persons SET firstname = {$firstname}, lastname = {$lastname} WHERE id = {$id}"); }
/** * Register function. * * @param string $username * @param string $password * @param \Entities\Person $person * @return boolean */ public function register($username, $password, Person $person) { $username = $this->pdo->quote($username); $password = $this->pdo->quote(sha1($password)); $personId = intval($person->getId()); $user = $this->pdo->query("SELECT * FROM users WHERE username = {$username}")->fetch(); if (!empty($user)) { return false; } $this->pdo->exec("INSERT INTO users(username, password, persons_id) VALUES({$username}, {$password}, {$personId})"); return true; }