summaryrefslogtreecommitdiff
path: root/classes/db/stmt.php
blob: 7d6bbb30a4dd7c37d55396f11f7248a073d68447 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
class Db_Stmt {
	private $stmt;
	private $cache;

	function __construct($stmt) {
		$this->stmt = $stmt;
		$this->cache = false;
	}

	function fetch_result($row, $param) {
		if (!$this->cache) {
			$this->cache = $this->stmt->fetchAll();
		}

		if (isset($this->cache[$row])) {
			return $this->cache[$row][$param];
		} else {
			user_error("Unable to jump to row $row", E_USER_WARNING);
			return false;
		}
	}

	function rowCount() {
		return $this->stmt->rowCount();
	}

	function fetch() {
		return $this->stmt->fetch();
	}
}