@@ -1334,20 +1334,21 @@ protected function getDriverFunctionPrefix(): string
1334
1334
/**
1335
1335
* Returns an array of table names
1336
1336
*
1337
- * @return array|bool
1337
+ * @return array|false
1338
1338
*
1339
1339
* @throws DatabaseException
1340
1340
*/
1341
1341
public function listTables (bool $ constrainByPrefix = false )
1342
1342
{
1343
- // Is there a cached result?
1344
1343
if (isset ($ this ->dataCache ['table_names ' ]) && $ this ->dataCache ['table_names ' ]) {
1345
- return $ constrainByPrefix ?
1346
- preg_grep ("/^ {$ this ->DBPrefix }/ " , $ this ->dataCache ['table_names ' ])
1344
+ return $ constrainByPrefix
1345
+ ? preg_grep ("/^ {$ this ->DBPrefix }/ " , $ this ->dataCache ['table_names ' ])
1347
1346
: $ this ->dataCache ['table_names ' ];
1348
1347
}
1349
1348
1350
- if (false === ($ sql = $ this ->_listTables ($ constrainByPrefix ))) {
1349
+ $ sql = $ this ->_listTables ($ constrainByPrefix );
1350
+
1351
+ if ($ sql === false ) {
1351
1352
if ($ this ->DBDebug ) {
1352
1353
throw new DatabaseException ('This feature is not available for the database you are using. ' );
1353
1354
}
@@ -1360,24 +1361,9 @@ public function listTables(bool $constrainByPrefix = false)
1360
1361
$ query = $ this ->query ($ sql );
1361
1362
1362
1363
foreach ($ query ->getResultArray () as $ row ) {
1363
- // Do we know from which column to get the table name?
1364
- if (! isset ($ key )) {
1365
- if (isset ($ row ['table_name ' ])) {
1366
- $ key = 'table_name ' ;
1367
- } elseif (isset ($ row ['TABLE_NAME ' ])) {
1368
- $ key = 'TABLE_NAME ' ;
1369
- } else {
1370
- /* We have no other choice but to just get the first element's key.
1371
- * Due to array_shift() accepting its argument by reference, if
1372
- * E_STRICT is on, this would trigger a warning. So we'll have to
1373
- * assign it first.
1374
- */
1375
- $ key = array_keys ($ row );
1376
- $ key = array_shift ($ key );
1377
- }
1378
- }
1364
+ $ table = $ row ['table_name ' ] ?? $ row ['TABLE_NAME ' ] ?? $ row [array_key_first ($ row )];
1379
1365
1380
- $ this ->dataCache ['table_names ' ][] = $ row [ $ key ] ;
1366
+ $ this ->dataCache ['table_names ' ][] = $ table ;
1381
1367
}
1382
1368
1383
1369
return $ this ->dataCache ['table_names ' ];
0 commit comments