PageRenderTime 27ms CodeModel.GetById 16ms app.highlight 6ms RepoModel.GetById 2ms app.codeStats 0ms

/framework/core/db/DbMysqlResult.php

http://zoop.googlecode.com/
PHP | 70 lines | 61 code | 9 blank | 0 comment | 8 complexity | 4e7657eb95fded6fea01341ab9fd5c9e MD5 | raw file
 1<?php
 2class DbMysqlResult extends DbResultSet
 3{
 4	private $cur;
 5	private $max;
 6
 7	function __construct($link, $res)
 8	{
 9		parent::__construct($link, $res);
10		if (gettype($res) == "boolean")
11		{
12			$this->res = null;
13			$this->cur = 0;
14			$this->max = 0;
15		}
16		else
17		{
18			$this->cur = 0;
19			$this->max = mysql_num_rows($this->res) - 1;
20		}
21	}
22
23	function numRows()
24	{
25		return $this->max + 1;
26	}
27
28	function rewind()
29	{
30		$this->cur = 0;
31	}
32
33	function current()
34	{
35		if($this->max == -1)
36			return false;
37		mysql_data_seek($this->res, $this->cur);
38		return mysql_fetch_assoc($this->res);
39	}
40
41	function key()
42	{
43		return $this->cur;
44	}
45
46	function next()
47	{
48		$this->cur++;
49		if($this->cur > $this->max)
50			return false;
51		mysql_data_seek($this->res, $this->cur);
52		return mysql_fetch_assoc($this->res);
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 == null)
66			return -1;
67		else
68			return mysql_affected_rows($this->link);
69	}
70}