MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
mdataset.class
Ir para a documentação deste ficheiro.
1
<?php
6
class
MDataSet
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
176
function
GetColumnName
(
$colNumber
)
177
{
178
return
$this->
metadata
[
'fieldname'
][
$colNumber
];
179
}
180
188
function
GetColumnNames
()
189
{
190
return
$this->
metadata
[
'fieldname'
];
191
}
192
202
function
GetColumnNumber
(
$colName
)
203
{
204
return
$this->
metadata
[
'fieldpos'
][
strtoupper
(
$colName
)];
205
}
206
216
function
GetValue
(
$colName
)
217
{
218
$result = $this->
result
[
$this->row
][$this->
metadata
[
'fieldpos'
][
strtoupper
(
$colName
)]];
219
return
$result
;
220
}
221
231
function
fields
(
$fieldName
)
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
{
282
$fieldvalues
=
array
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
{
329
$newResult
=
array
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
361
$newResult
=
array
362
(
363
);
364
365
if
(
$rs
= $this->
result
)
366
{
367
if
(!
is_array
(
$values
))
368
$values
=
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
391
$newResult
[
$sKey
] =
$sValue
;
392
}
393
394
return
$newResult
;
395
}
396
}
397
408
function
treeResult
(
$group
,
$node
)
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
449
class
RowObject
450
{
451
}
452
?>
MDataSet
Definição
mdataset.class:7
MDataSet\__construct
__construct()
Definição
mdataset.class:55
MDataSet\$result
$result
Definição
mdataset.class:11
MDataSet\SetRowObject
& SetRowObject($object)
Definição
mdataset.class:262
MDataSet\$rowCount
$rowCount
Definição
mdataset.class:21
MDataSet\$colCount
$colCount
Definição
mdataset.class:26
MDataSet\fields
fields($fieldName)
Definição
mdataset.class:231
MDataSet\$eof
$eof
Definição
mdataset.class:31
MDataSet\GetColumnNames
GetColumnNames()
Definição
mdataset.class:188
MDataSet\GetFieldValues
GetFieldValues()
Definição
mdataset.class:280
MDataSet\GetRowValues
GetRowValues()
Definição
mdataset.class:244
MDataSet\MovePrev
MovePrev()
Definição
mdataset.class:70
MDataSet\GetRowCount
GetRowCount()
Definição
mdataset.class:150
MDataSet\treeResult
treeResult($group, $node)
Definição
mdataset.class:408
MDataSet\GetColumnName
GetColumnName($colNumber)
Definição
mdataset.class:176
MDataSet\chunkResultMany
chunkResultMany($key, $values, $type='S', $separator='')
Definição
mdataset.class:358
MDataSet\$type
$type
Definição
mdataset.class:46
MDataSet\bof
bof()
Definição
mdataset.class:311
MDataSet\$row
$row
Definição
mdataset.class:16
MDataSet\GetRowObject
GetRowObject()
Definição
mdataset.class:256
MDataSet\GetColumnNumber
GetColumnNumber($colName)
Definição
mdataset.class:202
MDataSet\chunkResult
chunkResult($key=0, $value=1, $showKeyValue=false)
Definição
mdataset.class:327
MDataSet\GetColumnCount
GetColumnCount()
Definição
mdataset.class:162
MDataSet\MoveLast
MoveLast()
Definição
mdataset.class:138
MDataSet\eof
eof()
Definição
mdataset.class:299
MDataSet\GetValue
GetValue($colName)
Definição
mdataset.class:216
MDataSet\$metadata
$metadata
Definição
mdataset.class:41
MDataSet\MoveFirst
MoveFirst()
Definição
mdataset.class:126
MDataSet\MoveNext
MoveNext()
Definição
mdataset.class:87
MDataSet\MoveTo
MoveTo($row)
Definição
mdataset.class:106
MDataSet\$bof
$bof
Definição
mdataset.class:36
RowObject
Definição
mdataset.class:450
classes
database
mdataset.class
Gerado por
1.10.0