public function update(User $user) { $id = intval($user->getId()); $email = $this->db->quote($user->getEmail()); $name = $this->db->quote($user->getName()); $surname = $this->db->quote($user->getSurname()); $hash = $user->getHash(); $status = intval($user->getStatus()); $dateConnection = date('Y-m-d H:i:s', $user->getDateConnection()); $query = ' UPDATE user SET email = ' . $email . ', name = ' . $name . ', surname = ' . $surname . ', `hash` = "' . $hash . '", `status` = ' . $status . ', date_connection = "' . $dateConnection . '" WHERE id = ' . $id; $res = $this->db->exec($query); if ($res) { return $this->readById($id); } else { throw new Exception('Database error'); } }