Welcome to mirror list, hosted at ThFree Co, Russian Federation.

ArrayRecordSet.php « classes « src - github.com/HuasoFoundries/phpPgAdmin6.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2668321d29e605502d0e7866995ce7800ed441ed (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
<?php

/**
 * PHPPgAdmin 6.1.3
 */

namespace PHPPgAdmin;

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
{
    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);
    }

    /**
     * Counts the records in the instance array.
     *
     * @return int number of records in the instance array
     */
    public function recordCount()
    {
        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;
        }
    }
}