SQLiteResult.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Copyright (c) 2008-2023 the Urho3D project
  2. // License: MIT
  3. #pragma once
  4. #include "../../Core/Variant.h"
  5. #include <SQLite/sqlite3.h>
  6. namespace Urho3D
  7. {
  8. /// %Database query result.
  9. class URHO3D_API DbResult
  10. {
  11. friend class DbConnection;
  12. public:
  13. /// Default constructor constructs an empty result object.
  14. DbResult() :
  15. numAffectedRows_(-1)
  16. {
  17. }
  18. /// Return number of columns in the resultset or 0 if there is no resultset.
  19. unsigned GetNumColumns() const { return columns_.Size(); }
  20. /// Return number of rows in the resultset or 0 if the number of rows is not available.
  21. unsigned GetNumRows() const { return rows_.Size(); }
  22. /// Return number of affected rows by the DML query or -1 if the number of affected rows is not available.
  23. long GetNumAffectedRows() const { return numAffectedRows_; }
  24. /// Return the column headers string collection.
  25. const StringVector& GetColumns() const { return columns_; }
  26. /// Return fetched rows collection. Filtered rows are not included in the collection.
  27. const Vector<VariantVector>& GetRows() const { return rows_; }
  28. private:
  29. /// Column headers from the resultset.
  30. StringVector columns_;
  31. /// Fetched rows from the resultset.
  32. Vector<VariantVector> rows_;
  33. /// Number of affected rows by recent DML query.
  34. long numAffectedRows_;
  35. };
  36. }