1 | <?php |
||
23 | class PDOAdapter implements DataAdapterInterface |
||
24 | { |
||
25 | /** @var PDO */ |
||
26 | private $dataStorage; |
||
27 | /** @var string */ |
||
28 | private $dataGroup = null; |
||
29 | /** @var string */ |
||
30 | private $idKey = null; |
||
31 | |||
32 | /** |
||
33 | * PDOAdapter constructor. |
||
34 | * |
||
35 | * @param PDO $dataStorage |
||
36 | * |
||
37 | * @throws InvalidArgumentException |
||
38 | */ |
||
39 | 4 | public function __construct($dataStorage = null) |
|
59 | |||
60 | /** |
||
61 | * Returns the Data Storage instance. |
||
62 | * |
||
63 | * @return PDO |
||
64 | */ |
||
65 | 1 | public function getDataStorage() |
|
69 | |||
70 | /** |
||
71 | * Set adapter data group. For Databases this can be the Tables. |
||
72 | * |
||
73 | * @param string $dataGroup |
||
74 | * |
||
75 | * @throws InitException |
||
76 | * |
||
77 | * @return PDOAdapter |
||
78 | */ |
||
79 | 1 | public function setDataGroup($dataGroup) |
|
89 | |||
90 | /** |
||
91 | * Set adapter ID key. For Databases this can be the Primary key. Only simple key is allowed. |
||
92 | * |
||
93 | * @param string $idKey |
||
94 | * |
||
95 | * @throws InitException |
||
96 | * |
||
97 | * @return PDOAdapter |
||
98 | */ |
||
99 | 1 | public function setIdKey($idKey) |
|
109 | |||
110 | /** |
||
111 | * Get exactly one "row" of data according to the expression. |
||
112 | * |
||
113 | * @param mixed $identifier |
||
114 | * |
||
115 | * @return array |
||
116 | * |
||
117 | * @codeCoverageIgnore Don't test external library. |
||
118 | */ |
||
119 | public function getData($identifier) |
||
126 | |||
127 | /** |
||
128 | * Get a set of data according to the expression and the chunk. |
||
129 | * |
||
130 | * @param array $expression |
||
131 | * @param int $limit |
||
132 | * @param int $offset |
||
133 | * |
||
134 | * @return array |
||
135 | * |
||
136 | * @codeCoverageIgnore Don't test external library. |
||
137 | */ |
||
138 | public function getDataSet(array $expression, $limit = null, $offset = null) |
||
145 | |||
146 | /** |
||
147 | * Get the number of matched data in the set according to the expression. |
||
148 | * |
||
149 | * @param array $expression |
||
150 | * |
||
151 | * @return int |
||
152 | * |
||
153 | * @codeCoverageIgnore Don't test external library. |
||
154 | */ |
||
155 | public function getDataCardinality(array $expression) |
||
162 | |||
163 | /** |
||
164 | * Build query statement from the expression. |
||
165 | * |
||
166 | * @param array $expression |
||
167 | * @param int $limit |
||
168 | * @param int $offset |
||
169 | * |
||
170 | * @return PDOStatement |
||
171 | * |
||
172 | * @codeCoverageIgnore Don't test external library. |
||
173 | */ |
||
174 | private function getStatementForExpression(array $expression, $limit = null, $offset = null) |
||
208 | |||
209 | /** |
||
210 | * Insert or update entity in the storage. |
||
211 | * |
||
212 | * @param mixed $identifier |
||
213 | * @param array $data |
||
214 | * |
||
215 | * @return mixed The ID of the saved entity in the storage |
||
216 | * |
||
217 | * @codeCoverageIgnore Don't test external library. |
||
218 | */ |
||
219 | public function saveData($identifier, array $data) |
||
248 | |||
249 | /** |
||
250 | * Binds values to the statement. |
||
251 | * |
||
252 | * @param PDOStatement $statement |
||
253 | * @param array $queryBind |
||
254 | * |
||
255 | * @codeCoverageIgnore Don't test external library. |
||
256 | */ |
||
257 | private function bindValuesToStatement(PDOStatement &$statement, array $queryBind) |
||
271 | |||
272 | /** |
||
273 | * Removes an entity from the storage. |
||
274 | * |
||
275 | * @param mixed $identifier |
||
276 | * |
||
277 | * @return bool |
||
278 | * |
||
279 | * @codeCoverageIgnore Don't test external library. |
||
280 | */ |
||
281 | public function deleteData($identifier) |
||
287 | } |
||
288 |