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 NullManager. |
25
|
|
|
* |
26
|
|
|
* @author Melech Mizrachi |
27
|
|
|
*/ |
28
|
|
|
class NullManager 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
|
|
|
return true; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @inheritDoc |
56
|
|
|
*/ |
57
|
|
|
public function inTransaction(): bool |
58
|
|
|
{ |
59
|
|
|
return true; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @inheritDoc |
64
|
|
|
*/ |
65
|
|
|
public function ensureTransaction(): void |
66
|
|
|
{ |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @inheritDoc |
71
|
|
|
*/ |
72
|
|
|
public function prepare(string $query): Statement |
73
|
|
|
{ |
74
|
|
|
return new NullStatement(); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @inheritDoc |
79
|
|
|
*/ |
80
|
|
|
public function query(string $query): Statement |
81
|
|
|
{ |
82
|
|
|
return new NullStatement(); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* @inheritDoc |
87
|
|
|
*/ |
88
|
|
|
public function commit(): bool |
89
|
|
|
{ |
90
|
|
|
return true; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* @inheritDoc |
95
|
|
|
*/ |
96
|
|
|
public function rollback(): bool |
97
|
|
|
{ |
98
|
|
|
return true; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* @inheritDoc |
103
|
|
|
*/ |
104
|
|
|
public function lastInsertId(string|null $table = null, string|null $idField = null): string |
105
|
|
|
{ |
106
|
|
|
return 'id'; |
107
|
|
|
} |
108
|
|
|
} |
109
|
|
|
|