-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQueryManagerInterface.php
More file actions
105 lines (96 loc) · 2.69 KB
/
Copy pathQueryManagerInterface.php
File metadata and controls
105 lines (96 loc) · 2.69 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
<?php
namespace Bdf\Prime\Schema\Manager;
use Bdf\Prime\Exception\PrimeException;
use Exception;
/**
* Handle schema manager queries, like buffering, simulation, transaction...
*/
interface QueryManagerInterface
{
/**
* Push queries to execute
*
* @param mixed $queries Can be one or multiple queries. The type of the query depends on the platform.
*
* @return $this
* @throws PrimeException If auto flush is enabled and the query fail
*/
public function push($queries);
/**
* Simulate operations on schema
*
* <code>
* // Get changes
* $schema->simulate(function (SchemaManagerInterface $schema) {
* $schema->table(...);
* $schema->drop(...);
* })->pending();
*
* $buffered = $schema->simulate();
* $buffered->table(...);
* $buffered->flush();
* </code>
*
* To perform operations, you should use @see QueryManagerInterface::flush()
*
* @param callable(static):void|null $operations Operations to perform, or null for create a buffered SchemaManager
*
* @return static The simulated new SchemaManager
*/
public function simulate(?callable $operations = null);
/**
* Do operations into a transaction.
* A transaction is "All or nothing"
*
* <code>
* $schema->simulate(function (SchemaManagerInterface $schema) {
* $schema->table(...);
* $schema->truncate(...);
* });
* </code>
*
* @param callable(static):void $operations
*
* @return $this
*
* @throws PrimeException When transaction fail
* @throws Exception Rethrow $operations exception
* @throws \BadMethodCallException When the connection do not supports transations
*/
public function transaction(callable $operations);
/**
* Check if the SchemaManager use a buffer
*
* The schema manager is marqued as buffered on :
* @see QueryManagerInterface::simulate()
* @see QueryManagerInterface::transaction()
*
* @return boolean
*/
public function isBuffered(): bool;
/**
* Clear the cached queries
*
* @return $this
*/
public function clear();
/**
* Execute the modification to build / modify the schema.
* This method do nothing if it's not buffered
*
* @see QueryManagerInterface::isBuffered()
* @see QueryManagerInterface::simulate()
* @see QueryManagerInterface::transaction()
*
* @return bool
*
* @throws PrimeException When a pending query fail
*/
public function flush(): bool;
/**
* Get pending queries
*
* @return array
*/
public function pending(): array;
}