1 | <?php |
||
18 | abstract class AbstractIndex extends AbstractElement implements IndexInterface |
||
19 | { |
||
20 | /** |
||
21 | * Index types. |
||
22 | */ |
||
23 | const NORMAL = 'INDEX'; |
||
24 | const UNIQUE = 'UNIQUE'; |
||
25 | |||
26 | /** |
||
27 | * Index type, by default NORMAL and UNIQUE indexes supported, additional types can be |
||
28 | * implemented on database driver level. |
||
29 | * |
||
30 | * @var string |
||
31 | */ |
||
32 | protected $type = self::NORMAL; |
||
33 | |||
34 | /** |
||
35 | * Columns used to form index. |
||
36 | * |
||
37 | * @var array |
||
38 | */ |
||
39 | protected $columns = []; |
||
40 | |||
41 | /** |
||
42 | * {@inheritdoc} |
||
43 | * |
||
44 | * @param bool $quoted Quote name. |
||
45 | */ |
||
46 | public function getName($quoted = false) |
||
54 | |||
55 | /** |
||
56 | * {@inheritdoc} |
||
57 | */ |
||
58 | public function isUnique() |
||
62 | |||
63 | /** |
||
64 | * {@inheritdoc} |
||
65 | */ |
||
66 | public function getColumns() |
||
70 | |||
71 | /** |
||
72 | * Change index type and behaviour to unique/non-unique state. |
||
73 | * |
||
74 | * @param bool $unique |
||
75 | * |
||
76 | * @return $this |
||
77 | */ |
||
78 | public function unique($unique = true) |
||
84 | |||
85 | /** |
||
86 | * Change set of index forming columns. Method must support both array and string parameters. |
||
87 | * |
||
88 | * Example: |
||
89 | * $index->columns('key'); |
||
90 | * $index->columns('key', 'key2'); |
||
91 | * $index->columns(['key', 'key2']); |
||
92 | * |
||
93 | * @param string|array $columns Columns array or comma separated list of parameters. |
||
94 | * |
||
95 | * @return $this |
||
96 | */ |
||
97 | public function columns($columns) |
||
107 | |||
108 | /** |
||
109 | * Index sql creation syntax. |
||
110 | * |
||
111 | * @param bool $includeTable Include table ON statement (not required for inline index |
||
112 | * creation). |
||
113 | * |
||
114 | * @return string |
||
115 | */ |
||
116 | public function sqlStatement($includeTable = true) |
||
141 | |||
142 | /** |
||
143 | * Compare two elements together. |
||
144 | * |
||
145 | * @param self $initial |
||
146 | * |
||
147 | * @return bool |
||
148 | */ |
||
149 | public function compare(self $initial) |
||
156 | |||
157 | /** |
||
158 | * Generate unique index name. |
||
159 | * |
||
160 | * @return string |
||
161 | */ |
||
162 | protected function generateName() |
||
174 | } |
||
175 |