MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
mdataset.class
Ir para a documentação deste ficheiro.
1<?php
7{
11 var $result; // the dataset (an numeric-indexed array of rows x fields)
12
16 var $row; // the current row index
17
21 var $rowCount; // the row count
22
26 var $colCount; // the col count
27
31 var $eof; // true if row > nrows
32
36 var $bof; // true if row < 0
37
41 var $metadata; // an array with fieldname, fieldtype, fieldlength, fieldpos for the result
42
46 var $type; // query, table or storedproc
47
55 function __construct()
56 {
57 $this->eof = $this->bof = true;
58 $this->result = array
59 (
60 );
61 }
62
70 function MovePrev()
71 {
72 if ($this->bof = (--$this->row < 0))
73 {
74 $this->row = 0;
75 }
76
77 return $this->bof;
78 }
79
87 function MoveNext()
88 {
89 if ($this->eof = (++$this->row >= $this->rowCount))
90 {
91 $this->row = $this->rowCount - 1;
92 }
93
94 return $this->eof;
95 }
96
106 function MoveTo($row)
107 {
108 $inRange = (!$this->eof) && (($row < $this->rowCount) && ($row > -1));
109
110 if ($inRange)
111 {
112 $this->row = $row;
113 $this->bof = $this->eof = false;
114 }
115
116 return $inRange;
117 }
118
126 function MoveFirst()
127 {
128 return $this->MoveTo(0);
129 }
130
138 function MoveLast()
139 {
140 return $this->MoveTo($this->rowCount - 1);
141 }
142
150 function GetRowCount()
151 {
152 return $this->rowCount;
153 }
154
162 function GetColumnCount()
163 {
164 return $this->colCount;
165 }
166
177 {
178 return $this->metadata['fieldname'][$colNumber];
179 }
180
188 function GetColumnNames()
189 {
190 return $this->metadata['fieldname'];
191 }
192
203 {
204 return $this->metadata['fieldpos'][strtoupper($colName)];
205 }
206
217 {
218 $result = $this->result[$this->row][$this->metadata['fieldpos'][strtoupper($colName)]];
219 return $result;
220 }
221
232 {
233 $result = $this->result[$this->row][$this->metadata['fieldpos'][strtoupper($fieldName)]];
234 return $result;
235 }
236
244 function GetRowValues()
245 {
246 return $this->result[$this->row];
247 }
248
256 function GetRowObject()
257 {
258 $data = new RowObject();
259 return $this->SetRowObject($data);
260 }
261
262 function &SetRowObject($object)
263 {
264 for ($i = 0; $i < $this->colCount; $i++)
265 {
266 $fieldName = strtolower($this->metadata['fieldname'][$i]);
267 $object->$fieldName = $this->result[$this->row][$i];
268 }
269
270 return $object;
271 }
272
280 function GetFieldValues()
281 {
283 (
284 );
285
286 for ($i = 0; $i < $this->colCount; $i++)
287 $fieldvalues[$this->metadata['fieldname'][$i]] = $this->result[$this->row][$i];
288
289 return $fieldvalues;
290 }
291
299 function eof()
300 {
301 return (($this->eof) or ($this->rowCount == 0));
302 }
303
311 function bof()
312 {
313 return (($this->bof) or ($this->rowCount == 0));
314 }
315
327 function chunkResult($key = 0, $value = 1, $showKeyValue = false)
328 {
330 (
331 );
332
333 if ($rs = $this->result)
334 {
335 foreach ($rs as $row)
336 {
337 $sKey = trim($row[$key]);
338 $sValue = trim($row[$value]);
339 $newResult[$sKey] = ($showKeyValue ? $sKey . " - " : '') . $sValue;
340 }
341 }
342
343 return $newResult;
344 }
345
358 function chunkResultMany($key, $values, $type = 'S', $separator = '')
359 {
360 // type= 'S' : string, otherwise array
362 (
363 );
364
365 if ($rs = $this->result)
366 {
367 if (!is_array($values))
369
370 foreach ($rs as $row)
371 {
372 $sKey = trim($row[$key]);
373
374 if ($type == 'S')
375 {
376 $sValue = '';
377
378 foreach ($values as $v)
379 $sValue .= trim($row[$v]) . $separator;
380 }
381 else
382 {
383 $sValue = array
384 (
385 );
386
387 foreach ($values as $v)
388 $sValue[] = trim($row[$v]);
389 }
390
392 }
393
394 return $newResult;
395 }
396 }
397
409 {
410 $tree = array
411 (
412 );
413
414 if ($rs = $this->result)
415 {
416 $tree = array
417 (
418 );
419
420 $node = explode(',', $node);
421 $group = explode(',', $group);
422
423 foreach ($rs as $row)
424 {
425 $aNode = array
426 (
427 );
428
429 foreach ($node as $n)
430 $aNode[] = $row[$n];
431
432 $s = '';
433
434 foreach ($group as $g)
435 $s .= '[$row[' . $g . ']]';
436
437 eval ("\$tree$s" . "[] = \$aNode;");
438 }
439 }
440
441 return $tree;
442 }
443}
444
450{
451}
452?>
__construct()
Definição mdataset.class:55
& SetRowObject($object)
Definição mdataset.class:262
fields($fieldName)
Definição mdataset.class:231
GetColumnNames()
Definição mdataset.class:188
GetFieldValues()
Definição mdataset.class:280
GetRowValues()
Definição mdataset.class:244
treeResult($group, $node)
Definição mdataset.class:408
GetColumnName($colNumber)
Definição mdataset.class:176
chunkResultMany($key, $values, $type='S', $separator='')
Definição mdataset.class:358
GetRowObject()
Definição mdataset.class:256
GetColumnNumber($colName)
Definição mdataset.class:202
chunkResult($key=0, $value=1, $showKeyValue=false)
Definição mdataset.class:327
GetColumnCount()
Definição mdataset.class:162
GetValue($colName)
Definição mdataset.class:216
MoveTo($row)
Definição mdataset.class:106