public function AddPersistentLogin(\model\User $user) { try { // Assert that token is hashed assert($user->IsTokenHashed()); // Assert that user has id assert(is_numeric($user->GetUserId())); // Prepare db statement $statement = self::$db->prepare('UPDATE ' . self::$DB_TABLE_NAME . ' SET `user_token_hash` = :token' . ' WHERE `user_id` = :userId'); // Prepare input array $inputArray = ['userId' => $user->GetUserId(), 'token' => $user->GetToken()]; // Execute db statement $statement->execute($inputArray); // Check if db insertion was successful return $statement->rowCount() == 1; } catch (\Exception $exception) { throw new \Exception(self::$DB_UPDATE_ERROR); } }