/framework/core/db/DbPdoResult.php

http://zoop.googlecode.com/ · PHP · 69 lines · 53 code · 10 blank · 6 comment · 4 complexity · 253e833ea6b25d3123c6158846d24836 MD5 · raw file

  1. <?php
  2. class DbPdoResult extends DbResultSet
  3. {
  4. /**
  5. * Stores a reference to the PDOStatement object used by the resultset
  6. *
  7. * @var PDOStatement PDOStatement object
  8. */
  9. var $res;
  10. var $cur;
  11. var $max;
  12. private $rows;
  13. function DbPdoResult($link, $res)
  14. {
  15. parent::__construct($link, $res);
  16. $this->cur = 0;
  17. //EchoBacktrace();
  18. if(!$this->res)
  19. $this->rows = array();
  20. else
  21. $this->rows = $this->res->fetchAll();
  22. $this->max = count($this->rows) - 1;
  23. }
  24. function numRows()
  25. {
  26. return $this->max + 1;
  27. }
  28. function rewind()
  29. {
  30. $this->cur = 0;
  31. }
  32. function current()
  33. {
  34. return $this->rows[$this->cur];
  35. }
  36. function key()
  37. {
  38. return $this->cur;
  39. }
  40. function next()
  41. {
  42. $this->cur++;
  43. if($this->cur > $this->max)
  44. return false;
  45. return $this->rows[$this->cur];
  46. }
  47. function valid()
  48. {
  49. if($this->cur > $this->max)
  50. return false;
  51. return true;
  52. }
  53. function affectedRows()
  54. {
  55. if(!$this->res)
  56. return 0;
  57. return $this->res->rowCount();
  58. }
  59. }