You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
1.5 KiB

  1. #pragma once
  2. #include "result.h"
  3. namespace cppmariadb
  4. {
  5. /* result ************************************************************************************/
  6. result::result(MYSQL_RES* h)
  7. : handle (h)
  8. , _is_initialized (false)
  9. , _rowindex (static_cast<unsigned long long>(-1))
  10. { }
  11. unsigned int result::columncount() const
  12. { return mysql_num_fields(*this); }
  13. const column_vector& result::columns() const
  14. {
  15. if (_columns.empty())
  16. update_columns();
  17. return _columns;
  18. }
  19. row* result::current() const
  20. { return _row.get(); }
  21. unsigned long long result::rowindex() const
  22. { return _rowindex; }
  23. void result::free()
  24. {
  25. auto h = get_handle();
  26. handle(nullptr);
  27. mysql_free_result(h);
  28. }
  29. void result::rowindex(unsigned long long value)
  30. { _rowindex = value; }
  31. /* result_stored ******************************************************************************/
  32. result_stored::result_stored(MYSQL_RES* h)
  33. : result(h)
  34. { }
  35. void result_stored::rowindex(unsigned long long index)
  36. {
  37. result::rowindex(index);
  38. mysql_data_seek(*this, result::rowindex());
  39. }
  40. unsigned long long result_stored::rowcount() const
  41. { return mysql_num_rows(*this); }
  42. /* result_used *******************************************************************************/
  43. result_used::result_used(MYSQL_RES* h)
  44. : result(h)
  45. { }
  46. }