51ff3226 |
1 | <?php |
2 | class result { |
3 | var $_numRows = 0; |
4 | var $_numFields = 0; |
5 | var $_currentRow = -1; |
6 | var $_currentRecord = array(); |
7 | var $_queryId = false; |
8 | var $_sql = ""; |
9 | |
10 | function result($queryId, $sql) { |
11 | $this->_queryId = $queryId; |
12 | $this->_sql = $sql; |
13 | if ($this->_queryId != false) { |
14 | $this->_numRows = @mysql_num_rows($this->_queryId); |
15 | $this->_numFields = @mysql_num_fields($this->_queryId); |
16 | $this->_currentRow = -1; |
17 | $this->_currentRecord = array(); |
18 | } else { |
19 | $this->exception("result failed."); |
20 | } |
21 | } |
22 | |
23 | function next() { |
24 | if ($this->_currentRow + 1 >= $this->_numRows) { |
25 | return false; |
26 | } else { |
27 | $this->_currentRecord = @mysql_fetch_assoc($this->_queryId); |
28 | $this->_currentRow++; |
29 | return true; |
30 | } |
31 | } |
32 | |
d068d94b |
33 | /* DEPRECATED! |
51ff3226 |
34 | function absolute($row) { |
35 | if ($row > 0) { |
36 | // positive row number |
37 | @mysql_data_seek($this->_queryId, $row-1); |
38 | $this->_currentRecord = @mysql_fetch_assoc($this->_queryId); |
39 | $this->_currentRow = $row; |
40 | } elseif ($row < 0) { |
41 | // not implemented yet |
42 | } else { |
43 | $this->exception("Cannot absolute position to row 0"); |
44 | } |
45 | } |
d068d94b |
46 | */ |
51ff3226 |
47 | |
48 | function getRecord() { |
49 | return $this->_currentRecord; |
50 | } |
51 | |
52 | function getString($column) { |
53 | if (is_int($column) == true) { |
54 | return (string)$this->_currentRecord[$column-1]; |
55 | } else { |
56 | return (string)$this->_currentRecord["$column"]; |
57 | } |
58 | } |
59 | |
60 | function getInt($column) { |
61 | if (is_int($column) == true) { |
62 | return (int)$this->_currentRecord[$column-1]; |
63 | } else { |
64 | return (int)$this->_currentRecord["$column"]; |
65 | } |
66 | } |
67 | |
d068d94b |
68 | /* DEPRECATED! |
51ff3226 |
69 | function getVariable($column) { |
70 | return (int)$this->_currentRecord["$column"]; |
71 | |
72 | } |
73 | |
74 | function getDouble() { |
75 | if (is_int($column) == true) { |
76 | return (double)$this->_currentRecord[$column-1]; |
77 | } else { |
78 | return (double)$this->_currentRecord["$column"]; |
79 | } |
80 | } |
81 | |
82 | function getRow() { |
83 | if ($this->_currentRow < 0) { |
84 | return 0; |
85 | } else { |
86 | return $this->_currentRow + 1; |
87 | } |
88 | } |
d068d94b |
89 | */ |
51ff3226 |
90 | |
91 | function getNumRows() { |
92 | return $this->_numRows; |
93 | } |
94 | |
d068d94b |
95 | /* DEPRECATED! |
51ff3226 |
96 | function getNumFields() { |
97 | return $this->_numFields; |
98 | } |
d068d94b |
99 | */ |
51ff3226 |
100 | |
d068d94b |
101 | function exception($errorMsg) { //Internal only! |
51ff3226 |
102 | die("<pre>SQLException: ".$msg."</pre>"); |
103 | } |
104 | |
105 | } |
106 | |
d068d94b |
107 | ?> |