1 | <?php |
||
8 | trait Indexes |
||
9 | { |
||
10 | /** |
||
11 | * Add a new index command to the blueprint. |
||
12 | * |
||
13 | * @param string $type |
||
14 | * @param string|array|null $columns |
||
15 | * @param $name |
||
16 | * @param array $indexOptions |
||
17 | * @return Fluent |
||
18 | */ |
||
19 | protected function indexCommand($type = '', $columns = null, $name = null, $indexOptions = []) |
||
37 | |||
38 | |||
39 | |||
40 | /** |
||
41 | * Specify an index for the table. |
||
42 | * |
||
43 | * @param string|array $columns |
||
44 | * @param string $name |
||
45 | * @param string|null $algorithm |
||
46 | * @return Fluent |
||
47 | */ |
||
48 | public function index($columns = null, $name = null, $algorithm = null) |
||
54 | |||
55 | /** |
||
56 | * Create a hash index for fast exact matching. |
||
57 | * |
||
58 | * @param null $columns |
||
59 | * @param array $indexOptions |
||
60 | * @return Fluent |
||
61 | */ |
||
62 | public function hashIndex($columns = null, $indexOptions = []) |
||
66 | |||
67 | /** |
||
68 | * @param null|string $column |
||
69 | * @param $name |
||
70 | * @param array $indexOptions |
||
71 | * @return Fluent |
||
72 | */ |
||
73 | public function fulltextIndex($column = null, $name = null, $indexOptions = []) |
||
77 | |||
78 | /** |
||
79 | * Specify a spatial index for the table. |
||
80 | * |
||
81 | * @param $columns |
||
82 | * @param null $name |
||
83 | * @param array $indexOptions |
||
84 | * @return Fluent |
||
85 | */ |
||
86 | public function geoIndex($columns, $name = null, $indexOptions = []) |
||
90 | |||
91 | /** |
||
92 | * Specify a spatial index for the table. |
||
93 | * @param string|array $columns |
||
94 | * @param string $name |
||
95 | * @return Fluent |
||
96 | */ |
||
97 | public function spatialIndex($columns, $name = null) |
||
101 | |||
102 | /** |
||
103 | * @param $columns |
||
104 | * @param string|null $name |
||
105 | * @param array $indexOptions |
||
106 | * @return Fluent |
||
107 | */ |
||
108 | public function skiplistIndex($columns, $name = null, $indexOptions = []) |
||
112 | |||
113 | public function persistentIndex($columns, $name = null, $indexOptions = []) |
||
117 | |||
118 | /** |
||
119 | * Create a TTL index for the table. |
||
120 | * |
||
121 | * @param $columns |
||
122 | * @param null $name |
||
123 | * @param array $indexOptions |
||
124 | * @return Fluent |
||
125 | */ |
||
126 | public function ttlIndex($columns, $name = null, $indexOptions = []) |
||
130 | |||
131 | /** |
||
132 | * Specify a unique index for the table. |
||
133 | * |
||
134 | * @param string|array $columns |
||
135 | * @param string $name |
||
136 | * @param string|null $algorithm |
||
137 | * @return Fluent |
||
138 | */ |
||
139 | public function unique($columns = null, $name = null, $algorithm = null) |
||
147 | |||
148 | /** |
||
149 | * @param $command |
||
150 | * @throws Exception |
||
151 | */ |
||
152 | public function executeIndexCommand($command) |
||
173 | |||
174 | /** |
||
175 | * Indicate that the given index should be dropped. |
||
176 | * |
||
177 | * @param $name |
||
178 | * @return Fluent |
||
179 | */ |
||
180 | public function dropIndex($name) |
||
189 | |||
190 | /** |
||
191 | * Drop the index by first getting all the indexes on the table; then selecting the matching one |
||
192 | * by type and columns. |
||
193 | * @param $command |
||
194 | */ |
||
195 | public function executeDropIndexCommand($command) |
||
203 | |||
204 | /** |
||
205 | * @param string|null $algorithm |
||
206 | * @return mixed|string |
||
207 | */ |
||
208 | protected function mapIndexType($algorithm) |
||
220 | |||
221 | /** |
||
222 | * Create a default index name for the table. |
||
223 | * |
||
224 | * @param string $type |
||
225 | * @param array $columns |
||
226 | * @return string |
||
227 | */ |
||
228 | public function createIndexName($type, array $columns) |
||
234 | |||
235 | |||
236 | } |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: