PageRenderTime 96ms CodeModel.GetById 93ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 1ms

/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
 2class 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
14	function DbPdoResult($link, $res)
15	{
16		parent::__construct($link, $res);
17		$this->cur = 0;
18		//EchoBacktrace();
19		if(!$this->res)
20			$this->rows = array();
21		else
22			$this->rows = $this->res->fetchAll();
23		$this->max = count($this->rows) - 1;
24	}
25
26	function numRows()
27	{
28		return $this->max + 1;
29	}
30
31
32	function rewind()
33	{
34		$this->cur = 0;
35	}
36
37	function current()
38	{
39		return $this->rows[$this->cur];
40	}
41
42	function key()
43	{
44		return $this->cur;
45	}
46
47	function next()
48	{
49		$this->cur++;
50		if($this->cur > $this->max)
51			return false;
52		return $this->rows[$this->cur];
53	}
54
55	function valid()
56	{
57		if($this->cur > $this->max)
58			return false;
59
60		return true;
61	}
62
63	function affectedRows()
64	{
65		if(!$this->res)
66			return 0;
67		return $this->res->rowCount();
68	}
69}