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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
<?php class cResultSet { var $result; var $columns; var $rows; var $fieldNames;
function cResultSet($resource) { if($resource!=NULL) $this->set($resource); else { $this->rows = 0; $this->columns = 0; $this->fieldNames = NULL; $this->result = NULL; } }
function getColumnType($column) { if(is_resource($this->result)) return @@mysql_field_type($result, intval($column)); return null; }
function set($resource) { if(is_resource($resource)) { $this->columns = mysql_num_fields($resource); $this->rows = @mysql_num_rows($resource); $this->result = $resource; $this->setFieldNames(); } else { $this->result = NULL; $this->columns = 0; $this->rows = 0; $this->fieldNames = NULL; } }
function fetchRow($type = 2) { if (is_resource($this->result)) return @mysql_fetch_array($rs,$type);
return null; }
function getCoulumnsCount() { return $this->columns; } function getRowsCount() { return $this->rows; }
function setFieldNames() { for($i = 0; $i < $this->columns; $i++) $this->fieldNames[$i] = mysql_field_name($this->result, $i); return true; }
function getIndexByName($fieldName) { for($i = 0; $i<$this->columns; $i++) { if($this->fieldNames[$i] == $fieldName) return $i; } return -1; }
function getValueByIndex($row, $index) { if(($this->columns > $index) && is_resource($this->result)) return mysql_result($this->result, $row, $index); return null; }
function getValueByName($fieldName, $index) { $pos = getIndexByName($fieldName); if($pos == -1) return NULL;
$data = mysql_fetch_row($this->result, $index); return $data[$pos]; }
function isEmpty() { if($this->rows == 0) return true; return false; }
function getRow($index) { if($index >= $this->rows) { return null; }
return mysql_fetch_row($this->result, $index); }
function freeResult() { if(is_resource($this->result)) { @mysql_free_result($this->result); $this->result = NULL; } } }
?>
|