1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of UnderQuery package. |
5
|
|
|
* |
6
|
|
|
* Copyright (c) 2016 Beniamin Jonatan Šimko |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Phuria\UnderQuery\Statement; |
13
|
|
|
|
14
|
|
|
use Phuria\UnderQuery\Parameter\QueryParameterInterface; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @author Beniamin Jonatan Šimko <[email protected]> |
18
|
|
|
*/ |
19
|
|
|
class PDOStatement extends AbstractStatement |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @var \PDOStatement |
23
|
|
|
*/ |
24
|
|
|
private $wrappedStatement; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @param \PDOStatement $stmt |
28
|
|
|
*/ |
29
|
1 |
|
public function __construct(\PDOStatement $stmt) |
30
|
|
|
{ |
31
|
1 |
|
$this->wrappedStatement = $stmt; |
32
|
1 |
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @return \PDOStatement |
36
|
|
|
*/ |
37
|
|
|
public function getWrappedStatement() |
38
|
|
|
{ |
39
|
|
|
return $this->wrappedStatement; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @inheritdoc |
44
|
|
|
*/ |
45
|
|
|
public function bindParameter(QueryParameterInterface $parameter) |
46
|
|
|
{ |
47
|
|
|
$this->bindValue($parameter->getName(), $parameter->getValue()); |
48
|
|
|
|
49
|
|
|
return $this; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @inheritdoc |
54
|
|
|
*/ |
55
|
|
|
public function bindValue($name, $value) |
56
|
|
|
{ |
57
|
|
|
$this->wrappedStatement->bindValue($name, $value); |
58
|
|
|
|
59
|
|
|
return $this; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @inheritdoc |
64
|
|
|
*/ |
65
|
1 |
|
public function execute() |
66
|
|
|
{ |
67
|
1 |
|
$this->wrappedStatement->execute(); |
68
|
|
|
|
69
|
1 |
|
return $this; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @inheritdoc |
74
|
|
|
*/ |
75
|
1 |
|
public function rowCount() |
76
|
|
|
{ |
77
|
1 |
|
return $this->wrappedStatement->rowCount(); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @inheritdoc |
82
|
|
|
*/ |
83
|
1 |
|
public function closeCursor() |
84
|
|
|
{ |
85
|
1 |
|
$this->wrappedStatement->closeCursor(); |
86
|
|
|
|
87
|
1 |
|
return $this; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* @inheritdoc |
92
|
|
|
*/ |
93
|
|
|
public function fetch($fetchStyle = null, $cursorOrientation = \PDO::FETCH_ORI_NEXT, $cursorOffset = 0) |
94
|
|
|
{ |
95
|
|
|
return $this->wrappedStatement->fetch($fetchStyle, $cursorOrientation, $cursorOffset); |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* @inheritdoc |
100
|
|
|
*/ |
101
|
1 |
|
public function fetchColumn($column = 0) |
102
|
|
|
{ |
103
|
1 |
|
return $this->wrappedStatement->fetchColumn($column); |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* @inheritdoc |
108
|
|
|
*/ |
109
|
|
|
public function fetchAll($fetchStyle = null) |
110
|
|
|
{ |
111
|
|
|
return $this->fetchAll($fetchStyle); |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* @inheritdoc |
116
|
|
|
*/ |
117
|
|
|
public function fetchObject($className = 'stdClass', $constructorArguments = []) |
118
|
|
|
{ |
119
|
|
|
return $this->fetchObject($className, $constructorArguments); |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* @inheritdoc |
124
|
|
|
*/ |
125
|
|
|
public function fetchCallback(callable $callback) |
126
|
|
|
{ |
127
|
|
|
return $this->wrappedStatement->fetchAll(\PDO::FETCH_FUNC, $callback); |
128
|
|
|
} |
129
|
|
|
} |