1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the Valkyrja Framework package. |
7
|
|
|
* |
8
|
|
|
* (c) Melech Mizrachi <[email protected]> |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
11
|
|
|
* file that was distributed with this source code. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Valkyrja\Orm; |
15
|
|
|
|
16
|
|
|
use Valkyrja\Orm\Contract\Manager as Contract; |
17
|
|
|
use Valkyrja\Orm\QueryBuilder\Factory\Contract\QueryBuilderFactory; |
18
|
|
|
use Valkyrja\Orm\QueryBuilder\Factory\SqlQueryBuilderFactory; |
19
|
|
|
use Valkyrja\Orm\Repository\Contract\Repository; |
20
|
|
|
use Valkyrja\Orm\Statement\Contract\Statement; |
21
|
|
|
use Valkyrja\Orm\Statement\NullStatement; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Class InMemoryManager. |
25
|
|
|
* |
26
|
|
|
* @author Melech Mizrachi |
27
|
|
|
*/ |
28
|
|
|
class InMemoryManager implements Contract |
29
|
|
|
{ |
30
|
|
|
/** |
31
|
|
|
* @inheritDoc |
32
|
|
|
*/ |
33
|
|
|
public function createRepository(string $entity): Repository |
34
|
|
|
{ |
35
|
|
|
return new \Valkyrja\Orm\Repository\Repository($this, $entity); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @inheritDoc |
40
|
|
|
*/ |
41
|
|
|
public function createQueryBuilder(): QueryBuilderFactory |
42
|
|
|
{ |
43
|
|
|
return new SqlQueryBuilderFactory(); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @inheritDoc |
48
|
|
|
*/ |
49
|
|
|
public function beginTransaction(): bool |
50
|
|
|
{ |
51
|
|
|
// TODO: Implement beginTransaction() method. |
52
|
|
|
return true; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @inheritDoc |
57
|
|
|
*/ |
58
|
|
|
public function inTransaction(): bool |
59
|
|
|
{ |
60
|
|
|
// TODO: Implement inTransaction() method. |
61
|
|
|
return true; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @inheritDoc |
66
|
|
|
*/ |
67
|
|
|
public function ensureTransaction(): void |
68
|
|
|
{ |
69
|
|
|
// TODO: Implement ensureTransaction() method. |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @inheritDoc |
74
|
|
|
*/ |
75
|
|
|
public function prepare(string $query): Statement |
76
|
|
|
{ |
77
|
|
|
// TODO: Implement prepare() method. |
78
|
|
|
return new NullStatement(); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @inheritDoc |
83
|
|
|
*/ |
84
|
|
|
public function query(string $query): Statement |
85
|
|
|
{ |
86
|
|
|
// TODO: Implement query() method. |
87
|
|
|
return new NullStatement(); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* @inheritDoc |
92
|
|
|
*/ |
93
|
|
|
public function commit(): bool |
94
|
|
|
{ |
95
|
|
|
// TODO: Implement commit() method. |
96
|
|
|
return true; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @inheritDoc |
101
|
|
|
*/ |
102
|
|
|
public function rollback(): bool |
103
|
|
|
{ |
104
|
|
|
// TODO: Implement rollback() method. |
105
|
|
|
return true; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @inheritDoc |
110
|
|
|
*/ |
111
|
|
|
public function lastInsertId(string|null $table = null, string|null $idField = null): string |
112
|
|
|
{ |
113
|
|
|
// TODO: Implement lastInsertId() method. |
114
|
|
|
return 'id'; |
115
|
|
|
} |
116
|
|
|
} |
117
|
|
|
|