Search code examples
phpsql-server

MySQL PDO Fetch TableName like **


Search of table names has an answer with this code:

$Sql="SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME LIKE '%xxx%';

What is missing in all the answers is how to actually fetch the table name(s).

Something like:

$result=$db->query($Sql);
$Row=$result->fetch(); 
$TableNameFound=$Row['??'];

Solution

  • Here is the answer:

    $result=$db->query($Sql);
    $Row=$result->fetch(); 
    $TableNameFound=$Row['TABLE_NAME'];