1 | <?php |
||
29 | trait ConstraintFinderTrait |
||
30 | { |
||
31 | /** |
||
32 | * Returns the metadata of the given type for the given table. |
||
33 | * @param string $name table name. The table name may contain schema name if any. Do not quote the table name. |
||
34 | * @param string $type metadata type. |
||
35 | * @param bool $refresh whether to reload the table metadata even if it is found in the cache. |
||
36 | * @return mixed metadata. |
||
37 | */ |
||
38 | abstract protected function getTableMetadata($name, $type, $refresh); |
||
39 | |||
40 | /** |
||
41 | * Returns the metadata of the given type for all tables in the given schema. |
||
42 | * @param string $schema the schema of the metadata. Defaults to empty string, meaning the current or default schema name. |
||
43 | * @param string $type metadata type. |
||
44 | * @param bool $refresh whether to fetch the latest available table metadata. If this is `false`, |
||
45 | * cached data may be returned if available. |
||
46 | * @return array array of metadata. |
||
47 | */ |
||
48 | abstract protected function getSchemaMetadata($schema, $type, $refresh); |
||
49 | |||
50 | /** |
||
51 | * Loads a primary key for the given table. |
||
52 | * @param string $tableName table name. |
||
53 | * @return Constraint|null primary key for the given table, `null` if the table has no primary key. |
||
54 | */ |
||
55 | abstract protected function loadTablePrimaryKey($tableName); |
||
56 | |||
57 | /** |
||
58 | * Loads all foreign keys for the given table. |
||
59 | * @param string $tableName table name. |
||
60 | * @return ForeignKeyConstraint[] foreign keys for the given table. |
||
61 | */ |
||
62 | abstract protected function loadTableForeignKeys($tableName); |
||
63 | |||
64 | /** |
||
65 | * Loads all indexes for the given table. |
||
66 | * @param string $tableName table name. |
||
67 | * @return IndexConstraint[] indexes for the given table. |
||
68 | */ |
||
69 | abstract protected function loadTableIndexes($tableName); |
||
70 | |||
71 | /** |
||
72 | * Loads all unique constraints for the given table. |
||
73 | * @param string $tableName table name. |
||
74 | * @return Constraint[] unique constraints for the given table. |
||
75 | */ |
||
76 | abstract protected function loadTableUniques($tableName); |
||
77 | |||
78 | /** |
||
79 | * Loads all check constraints for the given table. |
||
80 | * @param string $tableName table name. |
||
81 | * @return CheckConstraint[] check constraints for the given table. |
||
82 | */ |
||
83 | abstract protected function loadTableChecks($tableName); |
||
84 | |||
85 | /** |
||
86 | * Loads all default value constraints for the given table. |
||
87 | * |
||
88 | * @param string $tableName table name. |
||
89 | * @return DefaultValueConstraint[] default value constraints for the given table. |
||
90 | */ |
||
91 | abstract protected function loadTableDefaultValues($tableName); |
||
92 | |||
93 | /** |
||
94 | * Obtains the primary key for the named table. |
||
95 | * @param string $name table name. The table name may contain schema name if any. Do not quote the table name. |
||
96 | * @param bool $refresh whether to reload the information even if it is found in the cache. |
||
97 | * @return Constraint|null table primary key, `null` if the table has no primary key. |
||
98 | */ |
||
99 | 38 | public function getTablePrimaryKey($name, $refresh = false) |
|
103 | |||
104 | /** |
||
105 | * Returns primary keys for all tables in the database. |
||
106 | * @param string $schema the schema of the tables. Defaults to empty string, meaning the current or default schema name. |
||
107 | * @param bool $refresh whether to fetch the latest available table schemas. If this is `false`, |
||
108 | * cached data may be returned if available. |
||
109 | * @return Constraint[] primary keys for all tables in the database. |
||
110 | * Each array element is an instance of [[Constraint]] or its child class. |
||
111 | */ |
||
112 | public function getSchemaPrimaryKeys($schema = '', $refresh = false) |
||
116 | |||
117 | /** |
||
118 | * Obtains the foreign keys information for the named table. |
||
119 | * @param string $name table name. The table name may contain schema name if any. Do not quote the table name. |
||
120 | * @param bool $refresh whether to reload the information even if it is found in the cache. |
||
121 | * @return ForeignKeyConstraint[] table foreign keys. |
||
122 | */ |
||
123 | 11 | public function getTableForeignKeys($name, $refresh = false) |
|
127 | |||
128 | /** |
||
129 | * Returns foreign keys for all tables in the database. |
||
130 | * @param string $schema the schema of the tables. Defaults to empty string, meaning the current or default schema name. |
||
131 | * @param bool $refresh whether to fetch the latest available table schemas. If this is false, |
||
132 | * cached data may be returned if available. |
||
133 | * @return ForeignKeyConstraint[][] foreign keys for all tables in the database. |
||
134 | * Each array element is an array of [[ForeignKeyConstraint]] or its child classes. |
||
135 | */ |
||
136 | public function getSchemaForeignKeys($schema = '', $refresh = false) |
||
140 | |||
141 | /** |
||
142 | * Obtains the indexes information for the named table. |
||
143 | * @param string $name table name. The table name may contain schema name if any. Do not quote the table name. |
||
144 | * @param bool $refresh whether to reload the information even if it is found in the cache. |
||
145 | * @return IndexConstraint[] table indexes. |
||
146 | */ |
||
147 | 30 | public function getTableIndexes($name, $refresh = false) |
|
151 | |||
152 | /** |
||
153 | * Returns indexes for all tables in the database. |
||
154 | * @param string $schema the schema of the tables. Defaults to empty string, meaning the current or default schema name. |
||
155 | * @param bool $refresh whether to fetch the latest available table schemas. If this is false, |
||
156 | * cached data may be returned if available. |
||
157 | * @return IndexConstraint[][] indexes for all tables in the database. |
||
158 | * Each array element is an array of [[IndexConstraint]] or its child classes. |
||
159 | */ |
||
160 | public function getSchemaIndexes($schema = '', $refresh = false) |
||
164 | |||
165 | /** |
||
166 | * Obtains the unique constraints information for the named table. |
||
167 | * @param string $name table name. The table name may contain schema name if any. Do not quote the table name. |
||
168 | * @param bool $refresh whether to reload the information even if it is found in the cache. |
||
169 | * @return Constraint[] table unique constraints. |
||
170 | */ |
||
171 | 38 | public function getTableUniques($name, $refresh = false) |
|
175 | |||
176 | /** |
||
177 | * Returns unique constraints for all tables in the database. |
||
178 | * @param string $schema the schema of the tables. Defaults to empty string, meaning the current or default schema name. |
||
179 | * @param bool $refresh whether to fetch the latest available table schemas. If this is false, |
||
180 | * cached data may be returned if available. |
||
181 | * @return Constraint[][] unique constraints for all tables in the database. |
||
182 | * Each array element is an array of [[Constraint]] or its child classes. |
||
183 | */ |
||
184 | public function getSchemaUniques($schema = '', $refresh = false) |
||
188 | |||
189 | /** |
||
190 | * Obtains the check constraints information for the named table. |
||
191 | * @param string $name table name. The table name may contain schema name if any. Do not quote the table name. |
||
192 | * @param bool $refresh whether to reload the information even if it is found in the cache. |
||
193 | * @return CheckConstraint[] table check constraints. |
||
194 | */ |
||
195 | 37 | public function getTableChecks($name, $refresh = false) |
|
199 | |||
200 | /** |
||
201 | * Returns check constraints for all tables in the database. |
||
202 | * @param string $schema the schema of the tables. Defaults to empty string, meaning the current or default schema name. |
||
203 | * @param bool $refresh whether to fetch the latest available table schemas. If this is false, |
||
204 | * cached data may be returned if available. |
||
205 | * @return CheckConstraint[][] check constraints for all tables in the database. |
||
206 | * Each array element is an array of [[CheckConstraint]] or its child classes. |
||
207 | */ |
||
208 | public function getSchemaChecks($schema = '', $refresh = false) |
||
212 | |||
213 | /** |
||
214 | * Obtains the default value constraints information for the named table. |
||
215 | * @param string $name table name. The table name may contain schema name if any. Do not quote the table name. |
||
216 | * @param bool $refresh whether to reload the information even if it is found in the cache. |
||
217 | * @return DefaultValueConstraint[] table default value constraints. |
||
218 | */ |
||
219 | 36 | public function getTableDefaultValues($name, $refresh = false) |
|
223 | |||
224 | /** |
||
225 | * Returns default value constraints for all tables in the database. |
||
226 | * @param string $schema the schema of the tables. Defaults to empty string, meaning the current or default schema name. |
||
227 | * @param bool $refresh whether to fetch the latest available table schemas. If this is false, |
||
228 | * cached data may be returned if available. |
||
229 | * @return DefaultValueConstraint[] default value constraints for all tables in the database. |
||
230 | * Each array element is an array of [[DefaultValueConstraint]] or its child classes. |
||
231 | */ |
||
232 | public function getSchemaDefaultValues($schema = '', $refresh = false) |
||
236 | } |
||
237 |