-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSQLDBResult.php
More file actions
60 lines (51 loc) · 1.33 KB
/
Copy pathSQLDBResult.php
File metadata and controls
60 lines (51 loc) · 1.33 KB
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
<?php
namespace MaxieSystems\DBAL;
class SQLDBResult extends DB\Result
{
public function __construct(\PDOStatement $sth, ?array $params = null)
{
$this->sth = $sth;
if ($params) {
parent::__construct($params);
}
}
public function __destruct()
{
$this->close();
}
final public function setFetchMode(int $mode, ...$args): DB\Result
{
if ($this->constructed()) {
throw new \Exception('Fetch mode can not be set after fetching data from DB.');
}
$this->sth->setFetchMode($mode, ...$args);
return $this;
}
final public function getQueryString(): string
{
if (null === $this->query_string) {
$this->query_string = $this->sth->queryString;
}
return $this->query_string;
}
final protected function open(): void
{
if ($p = $this->getParams()) {
SQLDB::bindValues($this->sth, $p);
}
$this->sth->execute();
parent::open();
}
final protected function close(): void
{
$this->query_string = $this->sth->queryString;
$this->sth->closeCursor();
parent::close();
}
final protected function fetchRow()
{
return $this->sth->fetch();
}
private $sth;
private $query_string = null;
}