-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMultiRepositoryReadOnlyInterface.php
More file actions
96 lines (88 loc) · 4.2 KB
/
MultiRepositoryReadOnlyInterface.php
File metadata and controls
96 lines (88 loc) · 4.2 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
<?php
namespace Squirrel\Entities;
/**
* INTERFACE: Multiple repositories should be read from (SELECT)
*/
interface MultiRepositoryReadOnlyInterface
{
/**
* Count number of entries. The options can be:
*
* - 'repositories': involved repositories as a name to RepositoryReadOnly / RepositoryBuilderReadOnlyInterface list
* - 'tables': how tables are connected and which are selected (optional, default is all)
* - 'where': WHERE restrictions
* - 'lock': if to lock selected entries (SELECT ... FOR UPDATE) for transaction (optional)
*
* @param array $query
* @psalm-param array{repositories:array,tables?:array,where:array,lock?:bool} $query
* @return int
*/
public function count(array $query): int;
/**
* Select query. The options can be:
*
* - 'repositories': involved repositories as a name to RepositoryReadOnly / RepositoryBuilderReadOnlyInterface list
* - 'tables': how tables are connected and which are selected (optional, default is all)
* - 'fields': what to select as a name to field name list
* - 'where': WHERE restrictions
* - 'group': GROUP BY definitions (optional)
* - 'order': ORDER BY definitions (optional)
* - 'limit': how many results to get (optional)
* - 'offset': at what record number to start (optional)
* - 'lock': if to lock selected entries (SELECT ... FOR UPDATE) for transaction (optional)
*
* A special possibility is a freeform query, with the following options:
*
* - 'repositories': involved repositories as a name to RepositoryConfigInterface list
* - 'fields': what to select as a name to field name list
* - 'query': Query as a string
* - 'parameters': Array of query value parameters
* - 'lock': if to lock selected entries (SELECT ... FOR UPDATE) for transaction (optional)
*
* Freeform queries should almost never be necessary and are not recommended, yet it is still a possibility
* because some queries (for example with subqueries or other complicated parts) cannot be structured yet might
* still be necessary or useful for performance or other reasons
*
* @param array $query
* @psalm-param array{repositories:array,tables?:array,fields:array,where?:array,group?:array,order?:array,limit?:int,offset?:int,lock?:bool,query?:string,parameters?:array} $query
* @return MultiRepositorySelectQueryInterface
*/
public function select(array $query): MultiRepositorySelectQueryInterface;
/**
* Find one entry from a result set and return it as an array
*
* @param MultiRepositorySelectQueryInterface $selectQuery
* @return array|null
*/
public function fetch(MultiRepositorySelectQueryInterface $selectQuery): ?array;
/**
* Clear existing result set
*
* @param MultiRepositorySelectQueryInterface $selectQuery
*/
public function clear(MultiRepositorySelectQueryInterface $selectQuery): void;
/**
* Select query and return one entry. The query options are the same as with the select function
*
* @param array $query
* @psalm-param array{repositories:array,tables?:array,fields:array,where?:array,group?:array,order?:array,limit?:int,offset?:int,lock?:bool,query?:string,parameters?:array} $query
* @return array
*/
public function fetchOne(array $query): ?array;
/**
* Select query and return all entries. The query options are the same as with the select function.
*
* @param array $query
* @psalm-param array{repositories:array,tables?:array,fields:array,where?:array,group?:array,order?:array,limit?:int,offset?:int,lock?:bool,query?:string,parameters?:array} $query
* @return array<int, array<string, mixed>>
*/
public function fetchAll(array $query): array;
/**
* Select query and return all entries as flattened values (no field names)
*
* @param array $query
* @psalm-param array{repositories:array,tables?:array,fields:array,where?:array,group?:array,order?:array,limit?:int,offset?:int,lock?:bool,query?:string,parameters?:array} $query
* @return array<bool|int|float|string|null>
*/
public function fetchAllAndFlatten(array $query): array;
}