Conditions | 3 |
Paths | 4 |
Total Lines | 19 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
44 | public function sqlStatement(Driver $driver, bool $includeTable = true): string |
||
45 | { |
||
46 | $statement = [$this->type == self::UNIQUE ? 'UNIQUE INDEX' : 'INDEX']; |
||
47 | |||
48 | //SQLite love to add indexes without being asked for that |
||
49 | $statement[] = 'IF NOT EXISTS'; |
||
50 | $statement[] = $driver->identifier($this->name); |
||
51 | |||
52 | if ($includeTable) { |
||
53 | $statement[] = "ON {$driver->identifier($this->table)}"; |
||
54 | } |
||
55 | |||
56 | //Wrapping column names |
||
57 | $columns = implode(', ', array_map([$driver, 'identifier'], $this->columns)); |
||
58 | |||
59 | $statement[] = "({$columns})"; |
||
60 | |||
61 | return implode(' ', $statement); |
||
62 | } |
||
63 | } |
||
64 |