1 | <?php |
||
8 | class Repository |
||
9 | { |
||
10 | |||
11 | /** |
||
12 | * @var Mapper |
||
13 | */ |
||
14 | protected $mapper; |
||
15 | |||
16 | /** |
||
17 | * @var DbDriverInterface |
||
18 | */ |
||
19 | protected $dbDriver = null; |
||
20 | |||
21 | /** |
||
22 | * Repository constructor. |
||
23 | * @param DbDriverInterface $dbDataset |
||
24 | * @param Mapper $mapper |
||
25 | */ |
||
26 | 21 | public function __construct(DbDriverInterface $dbDataset, Mapper $mapper) |
|
31 | |||
32 | /** |
||
33 | * @return Mapper |
||
34 | */ |
||
35 | 9 | public function getMapper() |
|
39 | |||
40 | /** |
||
41 | * @return DbDriverInterface |
||
42 | */ |
||
43 | 21 | protected function getDbDriver() |
|
47 | |||
48 | /** |
||
49 | * @param array|string $pkId |
||
50 | * @return mixed|null |
||
51 | */ |
||
52 | 14 | public function get($pkId) |
|
62 | |||
63 | /** |
||
64 | * @param array $pkId |
||
65 | * @return mixed|null |
||
66 | * @throws \Exception |
||
67 | */ |
||
68 | 2 | public function delete($pkId) |
|
77 | |||
78 | /** |
||
79 | * @param $updatable |
||
80 | * @return bool |
||
81 | * @throws \Exception |
||
82 | */ |
||
83 | 3 | public function deleteByQuery(Updatable $updatable) |
|
92 | |||
93 | /** |
||
94 | * @param string $filter |
||
95 | * @param array $params |
||
96 | * @param bool $forUpdate |
||
97 | * @return array |
||
98 | */ |
||
99 | 14 | public function getByFilter($filter, array $params, $forUpdate = false) |
|
111 | |||
112 | /** |
||
113 | * @param Query $query |
||
114 | * @param Mapper[] $mapper |
||
115 | * @return array |
||
116 | */ |
||
117 | 21 | public function getByQuery(Query $query, array $mapper = []) |
|
159 | |||
160 | /** |
||
161 | * @param mixed $instance |
||
162 | * @throws \Exception |
||
163 | */ |
||
164 | 8 | public function save($instance) |
|
202 | |||
203 | /** |
||
204 | * @param \ByJG\MicroOrm\Updatable $updatable |
||
205 | * @param array $params |
||
206 | * @return int |
||
207 | * @throws \Exception |
||
208 | */ |
||
209 | 5 | protected function insert(Updatable $updatable, array $params) |
|
218 | |||
219 | /** |
||
220 | * @param \ByJG\MicroOrm\Updatable $updatable |
||
221 | * @param array $params |
||
222 | * @return int |
||
223 | * @throws \Exception |
||
224 | */ |
||
225 | 4 | protected function insertWithAutoinc(Updatable $updatable, array $params) |
|
231 | |||
232 | /** |
||
233 | * @param \ByJG\MicroOrm\Updatable $updatable |
||
234 | * @param array $params |
||
235 | * @param $keyGen |
||
236 | * @return mixed |
||
237 | * @throws \Exception |
||
238 | */ |
||
239 | 1 | protected function insertWithKeyGen(Updatable $updatable, array $params, $keyGen) |
|
246 | |||
247 | /** |
||
248 | * @param \ByJG\MicroOrm\Updatable $updatable |
||
249 | * @param array $params |
||
250 | * @throws \Exception |
||
251 | */ |
||
252 | 3 | protected function update(Updatable $updatable, array $params) |
|
261 | } |
||
262 |