@@ -1334,20 +1334,21 @@ protected function getDriverFunctionPrefix(): string
13341334 /**
13351335 * Returns an array of table names
13361336 *
1337- * @return array|bool
1337+ * @return array|false
13381338 *
13391339 * @throws DatabaseException
13401340 */
13411341 public function listTables (bool $ constrainByPrefix = false )
13421342 {
1343- // Is there a cached result?
13441343 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 ' ])
13471346 : $ this ->dataCache ['table_names ' ];
13481347 }
13491348
1350- if (false === ($ sql = $ this ->_listTables ($ constrainByPrefix ))) {
1349+ $ sql = $ this ->_listTables ($ constrainByPrefix );
1350+
1351+ if ($ sql === false ) {
13511352 if ($ this ->DBDebug ) {
13521353 throw new DatabaseException ('This feature is not available for the database you are using. ' );
13531354 }
@@ -1360,24 +1361,9 @@ public function listTables(bool $constrainByPrefix = false)
13601361 $ query = $ this ->query ($ sql );
13611362
13621363 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 )];
13791365
1380- $ this ->dataCache ['table_names ' ][] = $ row [ $ key ] ;
1366+ $ this ->dataCache ['table_names ' ][] = $ table ;
13811367 }
13821368
13831369 return $ this ->dataCache ['table_names ' ];
0 commit comments