SqlResultset.php 927 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. namespace KarmaFW\Database\Sql;
  3. class SqlResultset implements SqlResultsetInterface
  4. {
  5. protected $rs = null;
  6. function __construct($rs)
  7. {
  8. $this->rs = $rs;
  9. }
  10. public function __debugInfo() {
  11. return [
  12. 'rs:protected' => is_object($this->rs) ? (get_class($this->rs) . ' Object') : (gettype($this->rs)),
  13. ];
  14. }
  15. public function fetchColumn($column_name)
  16. {
  17. $row = $this->fetchOne();
  18. if ($row) {
  19. return $row[$column_name];
  20. }
  21. return null;
  22. }
  23. public function one()
  24. {
  25. // Alias of fetchOne
  26. return $this->fetchOne();
  27. }
  28. public function fetchOne()
  29. {
  30. // extend me
  31. return null;
  32. }
  33. public function all()
  34. {
  35. // Alias of fetchAll
  36. return $this->fetchAll();
  37. }
  38. public function fetchAll()
  39. {
  40. $rows = [];
  41. while ($row = $this->fetchOne()) {
  42. $rows[] = $row;
  43. }
  44. return $rows;
  45. }
  46. public function getRowsCount()
  47. {
  48. // extend me
  49. return 0;
  50. }
  51. }