Skip to content
This repository was archived by the owner on Jan 9, 2024. It is now read-only.

Commit 7488059

Browse files
romanmirandamsonowal
authored andcommitted
Add escaped quotes to sql sentences
1 parent 04fc379 commit 7488059

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Services/IndexService.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ protected function createIndex()
7878
}
7979

8080
DB::connection($this->modelService->connectionName)
81-
->statement("CREATE FULLTEXT INDEX $indexName ON $tableName ($indexFields)");
81+
->statement("CREATE FULLTEXT INDEX `$indexName` ON `$tableName` ($indexFields)");
8282

8383
event(new Events\ModelIndexCreated($indexName, $indexFields));
8484
}
@@ -89,7 +89,7 @@ protected function indexAlreadyExists()
8989
$indexName = $this->modelService->indexName;
9090

9191
return !empty(DB::connection($this->modelService->connectionName)->
92-
select("SHOW INDEX FROM $tableName WHERE Key_name = ?", [$indexName]));
92+
select("SHOW INDEX FROM `$tableName` WHERE Key_name = ?", [$indexName]));
9393
}
9494

9595
protected function indexNeedsUpdate()
@@ -106,7 +106,7 @@ protected function getIndexFields()
106106
$tableName = $this->modelService->tablePrefixedName;
107107

108108
$index = DB::connection($this->modelService->connectionName)->
109-
select("SHOW INDEX FROM $tableName WHERE Key_name = ?", [$indexName]);
109+
select("SHOW INDEX FROM `$tableName` WHERE Key_name = ?", [$indexName]);
110110

111111
$indexFields = [];
112112

@@ -136,7 +136,7 @@ public function dropIndex()
136136

137137
if ($this->indexAlreadyExists()) {
138138
DB::connection($this->modelService->connectionName)
139-
->statement("ALTER TABLE $tableName DROP INDEX $indexName");
139+
->statement("ALTER TABLE `$tableName` DROP INDEX `$indexName`");
140140
event(new Events\ModelIndexDropped($this->modelService->indexName));
141141
}
142142
}

0 commit comments

Comments
 (0)