@@ -229,7 +229,14 @@ public function createDatabase(string $dbName, bool $ifNotExists = false): bool
229229 }
230230
231231 try {
232- if (! $ this ->db ->query (sprintf ($ ifNotExists ? $ this ->createDatabaseIfStr : $ this ->createDatabaseStr , $ dbName , $ this ->db ->charset , $ this ->db ->DBCollat ))) {
232+ if (! $ this ->db ->query (
233+ sprintf (
234+ $ ifNotExists ? $ this ->createDatabaseIfStr : $ this ->createDatabaseStr ,
235+ $ this ->db ->escapeIdentifier ($ dbName ),
236+ $ this ->db ->charset ,
237+ $ this ->db ->DBCollat
238+ )
239+ )) {
233240 // @codeCoverageIgnoreStart
234241 if ($ this ->db ->DBDebug ) {
235242 throw new DatabaseException ('Unable to create the specified database. ' );
@@ -268,7 +275,10 @@ private function databaseExists(string $dbName): bool
268275 return false ;
269276 }
270277
271- return $ this ->db ->query ($ this ->checkDatabaseExistStr , $ dbName )->getRow () !== null ;
278+ return $ this ->db ->query (
279+ $ this ->checkDatabaseExistStr ,
280+ $ this ->db ->escapeIdentifier ($ dbName )
281+ )->getRow () !== null ;
272282 }
273283
274284 /**
@@ -286,7 +296,9 @@ public function dropDatabase(string $dbName): bool
286296 return false ;
287297 }
288298
289- if (! $ this ->db ->query (sprintf ($ this ->dropDatabaseStr , $ dbName ))) {
299+ if (! $ this ->db ->query (
300+ sprintf ($ this ->dropDatabaseStr , $ this ->db ->escapeIdentifier ($ dbName ))
301+ )) {
290302 if ($ this ->db ->DBDebug ) {
291303 throw new DatabaseException ('Unable to drop the specified database. ' );
292304 }
@@ -295,7 +307,11 @@ public function dropDatabase(string $dbName): bool
295307 }
296308
297309 if (! empty ($ this ->db ->dataCache ['db_names ' ])) {
298- $ key = array_search (strtolower ($ dbName ), array_map ('strtolower ' , $ this ->db ->dataCache ['db_names ' ]), true );
310+ $ key = array_search (
311+ strtolower ($ dbName ),
312+ array_map ('strtolower ' , $ this ->db ->dataCache ['db_names ' ]),
313+ true
314+ );
299315 if ($ key !== false ) {
300316 unset($ this ->db ->dataCache ['db_names ' ][$ key ]);
301317 }
0 commit comments