Statement::rowCount()   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\Sqlite\Db\Sqlite;
4
5
use Lagdo\DbAdmin\Driver\Db\StatementInterface;
6
use Lagdo\DbAdmin\Driver\Entity\StatementFieldEntity;
7
8
use SQLite3Result;
9
10
class Statement implements StatementInterface
11
{
12
    /**
13
     * The query result
14
     *
15
     * @var SQLite3Result
16
     */
17
    protected $result = null;
18
19
    /**
20
     * Undocumented variable
21
     *
22
     * @var int
23
     */
24
    protected $offset = 0;
25
26
    /**
27
     * The constructor
28
     *
29
     * @param SQLite3Result $result
30
     */
31
    public function __construct(SQLite3Result $result)
32
    {
33
        $this->result = $result;
34
    }
35
36
    /**
37
     * @inheritDoc
38
     */
39
    public function rowCount()
40
    {
41
        return $this->result->numColumns();
42
    }
43
44
    /**
45
     * @inheritDoc
46
     */
47
    public function fetchAssoc()
48
    {
49
        return $this->result->fetchArray(SQLITE3_ASSOC);
50
    }
51
52
    /**
53
     * @inheritDoc
54
     */
55
    public function fetchRow()
56
    {
57
        return $this->result->fetchArray(SQLITE3_NUM);
58
    }
59
60
    /**
61
     * @inheritDoc
62
     */
63
    public function fetchField()
64
    {
65
        $column = $this->offset++;
66
        $type = $this->result->columnType($column);
67
        $name = $this->result->columnName($column);
68
        return new StatementFieldEntity($type, $type === SQLITE3_BLOB, $name, $name);
69
    }
70
71
    /**
72
     * The destructor
73
     */
74
    public function __destruct()
75
    {
76
        return $this->result->finalize();
77
    }
78
}
79