1 | <?php |
||
8 | abstract class AbstractMetadataReader |
||
9 | { |
||
10 | /** |
||
11 | * Keep static cache in memory. |
||
12 | * |
||
13 | * @var bool |
||
14 | */ |
||
15 | protected $cache_active = true; |
||
16 | |||
17 | /** |
||
18 | * @var array |
||
19 | */ |
||
20 | protected static $metadata_cache = []; |
||
21 | |||
22 | /** |
||
23 | * @param bool $active |
||
24 | * |
||
25 | * @return AbstractMetadataReader |
||
26 | */ |
||
27 | 1 | public function setStaticCache($active = true) |
|
33 | |||
34 | /** |
||
35 | * Return columns metadata from query. |
||
36 | * |
||
37 | * @throws Exception\UnsupportedTypeException |
||
38 | * @throws Exception\AmbiguousColumnException |
||
39 | * @throws Exception\InvalidQueryException |
||
40 | * |
||
41 | * @param string $sql |
||
42 | * |
||
43 | * @return ColumnsMetadata |
||
44 | */ |
||
45 | 18 | public function getColumnsMetadata($sql) |
|
59 | |||
60 | /** |
||
61 | * Return columns metadata from a table. |
||
62 | * |
||
63 | * @throws Exception\UnsupportedTypeException |
||
64 | * @throws Exception\AmbiguousColumnException |
||
65 | * @throws Exception\TableNotFoundException |
||
66 | * |
||
67 | * @param string $table |
||
68 | * |
||
69 | * @return ColumnsMetadata |
||
70 | */ |
||
71 | 2 | public function getTableMetadata($table) |
|
85 | |||
86 | /** |
||
87 | * Read metadata information from source. |
||
88 | * |
||
89 | * @throws Exception\UnsupportedTypeException |
||
90 | * @throws Exception\AmbiguousColumnException |
||
91 | * @throws \Soluble\Metadata\Exception\InvalidQueryException |
||
92 | * |
||
93 | * @param string $sql |
||
94 | * |
||
95 | * @return ColumnsMetadata |
||
96 | */ |
||
97 | abstract protected function readColumnsMetadata($sql); |
||
98 | |||
99 | /** |
||
100 | * Optimization, will add false condition to the query |
||
101 | * so the metadata loading will be faster. |
||
102 | * |
||
103 | * @param string $sql query string |
||
104 | * |
||
105 | * @return string |
||
106 | */ |
||
107 | 11 | protected function getEmptiedQuery($sql) |
|
132 | } |
||
133 |