blob: 17c2b43e263c47a55f20129b5a327c01d7ebe5f5 (
plain)
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
|
<?php
/**
* PHPPgAdmin 6.1.3
*/
namespace PHPPgAdmin;
use ADOFieldObject;
use Countable;
/**
* @file
* Really simple RecordSet to allow printTable of arrays.
*
* Id: ArrayRecordSet.php,v 1.3 2007/01/10 01:46:28 soranzo Exp $
*/
/**
* Really simple RecordSet to allow printTable arrays.
* Mimics the behavior of an ADORecordset.
*
* Id: ArrayRecordSet.php,v 1.3 2007/01/10 01:46:28 soranzo Exp $
*/
class ArrayRecordSet implements Countable , Interfaces\RecordSet
{
public $EOF = false;
public $fields;
private $_array;
/**
* Constructor.
*
* @param array $data The input array
*/
public function __construct($data)
{
$this->_array = $data;
$this->fields = \reset($this->_array);
if (false === $this->fields) {
$this->EOF = true;
}
}
/**
* Returns the recordCount.
*/
public function count(): int
{
return \count($this->_array);
}
function FetchField($off = 0): ADOFieldObject
{
// offsets begin at 0
$o= new ADOFieldObject();
$o->name= array_keys($this->fields)[$off]??null;
$value = $this->fields[$o->name??random_bytes(64)]??null;
$o->type= get_debug_type($value);
$o->max_length = 1024;
return $o;
}
/**
* Counts the records in the instance array.
*
* @return int number of records in the instance array
*/
public function RecordCount():int
{
return $this->count();
}
/**
* Advance the internal pointer of the instance array
* if no more fields are left, marks the instance variable $EOF as true.
*/
public function MoveNext(): void
{
$this->fields = \next($this->_array);
if (false === $this->fields) {
$this->EOF = true;
}
}
}
|