-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConnectionInterface.php
More file actions
executable file
·175 lines (158 loc) · 4.73 KB
/
Copy pathConnectionInterface.php
File metadata and controls
executable file
·175 lines (158 loc) · 4.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<?php
namespace Bdf\Prime\Connection;
use Bdf\Prime\Connection\Result\ResultSetInterface;
use Bdf\Prime\Exception\PrimeException;
use Bdf\Prime\Exception\QueryBuildingException;
use Bdf\Prime\Exception\QueryExecutionException;
use Bdf\Prime\Platform\PlatformInterface;
use Bdf\Prime\Query\CommandInterface;
use Bdf\Prime\Query\Compiler\Preprocessor\PreprocessorInterface;
use Bdf\Prime\Query\Contract\Compilable;
use Bdf\Prime\Query\Factory\QueryFactoryInterface;
use Bdf\Prime\Query\QueryInterface;
use Bdf\Prime\Query\ReadCommandInterface;
use Bdf\Prime\Schema\Manager\DatabaseManagerInterface;
use Bdf\Prime\Schema\SchemaManagerInterface;
use Bdf\Prime\Types\TypeInterface;
use Doctrine\Common\EventManager;
/**
* Base connection type
*
* Allows creating and executing queries, and handle a platform
*/
interface ConnectionInterface
{
/**
* Set the connection name
*
* @param string $name
*
* @return $this
*/
public function setName(string $name);
/**
* Get the connection name
*
* @return string
*/
public function getName(): string;
/**
* Gets the SchemaManager.
*
* @return DatabaseManagerInterface
* @throws PrimeException
*/
public function schema(): DatabaseManagerInterface;
/**
* Transform database value to PHP value
*
* @param mixed $value
* @param string|TypeInterface $type
*
* @param array $fieldOptions
* @return mixed
*
* @throws PrimeException When cannot convert value
*/
public function fromDatabase($value, $type, array $fieldOptions = []);
/**
* Transform PHP value to database value
*
* @param mixed $value
* @param null|string|TypeInterface $type
*
* @return mixed
*
* @throws PrimeException When cannot convert value
*/
public function toDatabase($value, $type = null);
/**
* Get a query builder
*
* @param PreprocessorInterface|null $preprocessor The compiler preprocessor to use
*
* @return ReadCommandInterface
*/
public function builder(?PreprocessorInterface $preprocessor = null): ReadCommandInterface;
/**
* Make a new query
*
* @param class-string<Q> $query The query name, or class name
* @param PreprocessorInterface|null $preprocessor The compiler preprocessor to use
*
* @return Q
*
* @template Q as CommandInterface
*/
public function make(string $query, ?PreprocessorInterface $preprocessor = null): CommandInterface;
/**
* Get the query factory for this connection
*
* @return QueryFactoryInterface
*/
public function factory(): QueryFactoryInterface;
/**
* Get a select query builder from table
*
* @param string|QueryInterface $table The "from" clause. Can be a table name or an embedded query
* @param string|null $alias The clause alias
*
* @return ReadCommandInterface
*/
public function from($table, ?string $alias = null): ReadCommandInterface;
/**
* Executes a raw select query and returns array of object
*
* @param mixed $query The raw query to execute
* @param array $bindings The query bindings
*
* @return ResultSetInterface<\stdClass> The database result, in object form
* @throws PrimeException When select fail
*/
public function select($query, array $bindings = []): ResultSetInterface;
/**
* Execute the query and get the result.
* The result may differ by the query type
*
* @param Compilable $query Query to execute
*
* @return ResultSetInterface<array<string, mixed>>
*
* @see Compilable::type() The query type
*
* @throws QueryExecutionException When query execution fail
* @throws QueryBuildingException When query compilation fail
* @throws PrimeException When execution fail
*/
public function execute(Compilable $query): ResultSetInterface;
/**
* Gets the name of the database this Connection is connected to.
*
* @return string|null
*/
public function getDatabase(): ?string;
/**
* Get the platform instance
*
* @return PlatformInterface
* @throws PrimeException
*/
public function platform(): PlatformInterface;
/**
* Gets the EventManager used by the Connection.
*
* @return EventManager
*
* @todo Ne pas utiliser l'event manager de doctrine ?
* C'est actuellement le plus simple et léger, mais ajoute une dépendence forte à Doctrine
*
* @internal
*/
public function getEventManager();
/**
* Closes the connection and trigger "onConnectionClosed" event
*
* @return void
*/
public function close(): void;
}