2 /* This program is free software. It comes without any warranty, to
3 * the extent permitted by applicable law. You can redistribute it
4 * and/or modify it under the terms of the Do What The Fuck You Want
5 * To Public License, Version 2, as published by Sam Hocevar. See
6 * http://sam.zoy.org/wtfpl/COPYING for more details. */
11 var $_currentRow = -1;
12 var $_currentRecord = array();
13 var $_queryId = false;
16 function result($queryId, $sql) {
17 $this->_queryId = $queryId;
19 if ($this->_queryId != false) {
20 $this->_numRows = @mysql_num_rows($this->_queryId);
21 $this->_numFields = @mysql_num_fields($this->_queryId);
22 $this->_currentRow = -1;
23 $this->_currentRecord = array();
25 $this->exception("result failed.");
30 if ($this->_currentRow + 1 >= $this->_numRows) {
33 $this->_currentRecord = @mysql_fetch_assoc($this->_queryId);
39 function absolute($row) {
41 // positive row number
42 @mysql_data_seek($this->_queryId, $row-1);
43 $this->_currentRecord = @mysql_fetch_assoc($this->_queryId);
44 $this->_currentRow = $row;
46 // not implemented yet
48 $this->exception("Cannot absolute position to row 0");
52 function getRecord() {
53 return $this->_currentRecord;
56 function getString($column) {
57 if (is_int($column) == true) {
58 return (string)$this->_currentRecord[$column-1];
60 return (string)$this->_currentRecord["$column"];
64 function getInt($column) {
65 if (is_int($column) == true) {
66 return (int)$this->_currentRecord[$column-1];
68 return (int)$this->_currentRecord["$column"];
72 function getVariable($column) {
73 return (int)$this->_currentRecord["$column"];
77 function getDouble() {
78 if (is_int($column) == true) {
79 return (double)$this->_currentRecord[$column-1];
81 return (double)$this->_currentRecord["$column"];
86 if ($this->_currentRow < 0) {
89 return $this->_currentRow + 1;
93 function getNumRows() {
94 return $this->_numRows;
97 function getNumFields() {
98 return $this->_numFields;
101 function exception($errorMsg) {
102 die("<pre>SQLException: ".$msg."</pre>");