1 | <?php |
||
10 | abstract class AbstractMetadataReader implements MetadataReaderInterface |
||
11 | { |
||
12 | /** |
||
13 | * Keep static cache in memory. |
||
14 | * |
||
15 | * @var bool |
||
16 | */ |
||
17 | protected $cache_active = true; |
||
18 | |||
19 | /** |
||
20 | * @var array |
||
21 | */ |
||
22 | protected static $metadata_cache = []; |
||
23 | |||
24 | /** |
||
25 | * @var string[] |
||
26 | */ |
||
27 | protected $capabilities = []; |
||
28 | |||
29 | /** |
||
30 | * @param bool $active |
||
31 | * |
||
32 | * @return AbstractMetadataReader |
||
33 | */ |
||
34 | 1 | public function setStaticCache(bool $active = true) |
|
40 | |||
41 | /** |
||
42 | * Return columns metadata from query. |
||
43 | * |
||
44 | * @throws Exception\UnsupportedTypeException |
||
45 | * @throws Exception\AmbiguousColumnException |
||
46 | * @throws Exception\InvalidQueryException |
||
47 | */ |
||
48 | 17 | public function getColumnsMetadata(string $sql): ColumnsMetadata |
|
62 | |||
63 | /** |
||
64 | * Return columns metadata from a table. |
||
65 | * |
||
66 | * @throws Exception\UnsupportedTypeException |
||
67 | * @throws Exception\AmbiguousColumnException |
||
68 | * @throws Exception\TableNotFoundException |
||
69 | */ |
||
70 | 2 | public function getTableMetadata(string $table): ColumnsMetadata |
|
84 | |||
85 | /** |
||
86 | * Read metadata information from source. |
||
87 | * |
||
88 | * @throws Exception\UnsupportedTypeException |
||
89 | * @throws Exception\AmbiguousColumnException |
||
90 | * @throws \Soluble\Metadata\Exception\InvalidQueryException |
||
91 | */ |
||
92 | abstract protected function readColumnsMetadata(string $sql): ColumnsMetadata; |
||
93 | |||
94 | /** |
||
95 | * Optimization, will add false condition to the query |
||
96 | * so the metadata loading will be faster. |
||
97 | */ |
||
98 | 10 | protected function getEmptiedQuery(string $sql): string |
|
123 | |||
124 | 19 | public function addCapability(string $name): void |
|
130 | |||
131 | public function hasCapability(string $name): bool |
||
135 | } |
||
136 |