/framework/core/db/DbPgResult.php

http://zoop.googlecode.com/ · PHP · 56 lines · 47 code · 9 blank · 0 comment · 4 complexity · 7d4c89b199407bc22728869344abdb09 MD5 · raw file

  1. <?php
  2. class DbPgResult extends DbResultSet
  3. {
  4. private $cur;
  5. private $max;
  6. function __construct($link, $res)
  7. {
  8. parent::__construct($link, $res);
  9. $this->cur = 0;
  10. $this->max = pg_num_rows($this->res) - 1;
  11. }
  12. function numRows()
  13. {
  14. return $this->max + 1;
  15. }
  16. function rewind()
  17. {
  18. $this->cur = 0;
  19. }
  20. function current()
  21. {
  22. if($this->max == -1)
  23. return false;
  24. return pg_fetch_assoc($this->res, $this->cur);
  25. }
  26. function key()
  27. {
  28. return $this->cur;
  29. }
  30. function next()
  31. {
  32. $this->cur++;
  33. if($this->cur > $this->max)
  34. return false;
  35. return pg_fetch_assoc($this->res, $this->cur);
  36. }
  37. function valid()
  38. {
  39. if($this->cur > $this->max)
  40. return false;
  41. return true;
  42. }
  43. function affectedRows()
  44. {
  45. return pg_affected_rows($this->res);
  46. }
  47. }