Statement::fetchRow()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Lagdo\DbAdmin\Driver\PgSql\Db\PgSql;
4
5
use Lagdo\DbAdmin\Driver\Db\StatementInterface;
6
use Lagdo\DbAdmin\Driver\Entity\StatementFieldEntity;
7
8
class Statement implements StatementInterface
9
{
10
    /**
11
     * @var resource
12
     */
13
    protected $result;
14
15
    /**
16
     * @var int
17
     */
18
    protected $offset = 0;
19
20
    /**
21
     * The constructor
22
     *
23
     * @param resource $result
24
     */
25
    public function __construct($result)
26
    {
27
        $this->result = $result;
28
    }
29
30
    /**
31
     * @inheritDoc
32
     */
33
    public function rowCount()
34
    {
35
        return pg_num_rows($this->result);
36
    }
37
38
    /**
39
     * @inheritDoc
40
     */
41
    public function fetchAssoc()
42
    {
43
        return pg_fetch_assoc($this->result);
44
    }
45
46
    /**
47
     * @inheritDoc
48
     */
49
    public function fetchRow()
50
    {
51
        return pg_fetch_row($this->result);
52
    }
53
54
    /**
55
     * @inheritDoc
56
     */
57
    public function fetchField()
58
    {
59
        $column = $this->offset++;
60
        // $table = function_exists('pg_field_table') ? pg_field_table($this->result, $column) : '';
61
        $table = pg_field_table($this->result, $column);
62
        $name = pg_field_name($this->result, $column);
63
        $type = pg_field_type($this->result, $column);
64
        return new StatementFieldEntity($type, $type === "bytea", $name, $name, $table, $table);
65
    }
66
67
    /**
68
     * The destructor
69
     */
70
    public function __destruct()
71
    {
72
        pg_free_result($this->result);
73
    }
74
}
75