-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDoctrineConnectionInterface.php
More file actions
130 lines (113 loc) · 4.03 KB
/
DoctrineConnectionInterface.php
File metadata and controls
130 lines (113 loc) · 4.03 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
<?php
/*
* This file is part of the Artemeon Core - Web Application Framework.
*
* (c) Artemeon <www.artemeon.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Artemeon\Database;
use Generator;
/**
* Interface, which is compatible to the Doctrine DBAL Connection class
* {@link https://github.com/doctrine/dbal/blob/3.3.x/src/Connection.php}.
*
* If your service uses only those new methods it is recommended to type hint against this DoctrineConnectionInterface
* interface instead of the ConnectionInterface.
*/
interface DoctrineConnectionInterface
{
/**
* Prepares and executes an SQL query and returns the result as an array of associative arrays.
*
* @param list<scalar|null> $params
*
* @return list<array<string, mixed>>
*/
public function fetchAllAssociative(string $query, array $params = []): array;
/**
* Prepares and executes an SQL query and returns the first row of the result
* as an associative array.
*
* @param list<scalar|null> $params
*
* @return array<string, mixed>|false
*/
public function fetchAssociative(string $query, array $params = []): array | false;
/**
* Prepares and executes an SQL query and returns the result as an array of the first column values.
*
* @param list<scalar|null> $params
*
* @return list<mixed>
*/
public function fetchFirstColumn(string $query, array $params = []): array;
/**
* Prepares and executes an SQL query and returns the value of a single column of the first row of the result.
*
* @param list<scalar|null> $params
*/
public function fetchOne(string $query, array $params = []): mixed;
/**
* Prepares and executes an SQL query and returns the result as an iterator over rows represented
* as associative arrays.
*
* @param list<scalar|null> $params
*/
public function iterateAssociative(string $query, array $params = []): Generator;
/**
* Prepares and executes an SQL query and returns the result as an iterator over the first column values.
*
* @param list<scalar|null> $params
*/
public function iterateColumn(string $query, array $params = []): Generator;
/**
* Executes an SQL statement with the given parameters and returns the number of affected rows.
*
* Could be used for:
* - DML statements: INSERT, UPDATE, DELETE, etc.
* - DDL statements: CREATE, DROP, ALTER, etc.
* - DCL statements: GRANT, REVOKE, etc.
* - Session control statements: ALTER SESSION, SET, DECLARE, etc.
* - Other statements that don't yield a row set.
*
* @param list<scalar|null> $params
*/
public function executeStatement(string $query, array $params = []): int;
/**
* Creates a simple insert for a single row where the values parameter is an associative array with column names to
* value mapping.
*
* @param array<non-empty-string, scalar|null> $values
* @param list<bool>|null $escapes
*/
public function insert(string $tableName, array $values, ?array $escapes = null): int;
/**
* Updates a row on the provided table by the identifier columns.
*
* @param array<string, scalar|null> $values
* @param array<string, scalar|null> $identifier
* @param list<bool>|null $escapes
*/
public function update(string $tableName, array $values, array $identifier, ?array $escapes = null): int;
/**
* Deletes a row on the provided table by the identifier columns.
*
* @param array<string, scalar|null> $identifier
*/
public function delete(string $tableName, array $identifier): int;
/**
* Starts a transaction.
*/
public function beginTransaction(): void;
/**
* Ends a transaction successfully.
*/
public function commit(): void;
/**
* Rollback of the current transaction.
*/
public function rollBack(): void;
}