stmt.php 534 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. class Db_Stmt {
  3. private $stmt;
  4. private $cache;
  5. function __construct($stmt) {
  6. $this->stmt = $stmt;
  7. $this->cache = false;
  8. }
  9. function fetch_result($row, $param) {
  10. if (!$this->cache) {
  11. $this->cache = $this->stmt->fetchAll();
  12. }
  13. if (isset($this->cache[$row])) {
  14. return $this->cache[$row][$param];
  15. } else {
  16. user_error("Unable to jump to row $row", E_USER_WARNING);
  17. return false;
  18. }
  19. }
  20. function rowCount() {
  21. return $this->stmt->rowCount();
  22. }
  23. function fetch() {
  24. return $this->stmt->fetch();
  25. }
  26. }