sql server - PHP MSSQL PDO get table names? -
i want array of tables remote database using pdo ( mssql ) notice cannot use mysql query commands , any advice how tables information mssql database using pdo or mssql ?
i able connect :
try { $hostname = $myserver; $port = 10060; $dbname = $mydb ; $username = $myuser ; $pw = $mypass; $dbh = new pdo ("mssql:host=$hostname;dbname=$dbname","$username","$pw"); } catch (pdoexception $e) { echo "failed db handle: " . $e->getmessage() . "\n"; exit; }
but not able data :
$q = $dbh->prepare("describe"); $q->execute(); $table_fields = $q->fetchall(pdo::fetch_column); print_r($table_fields); } catch (pdoexception $e) { echo "failed db handle: " . $e->getmessage() . "\n"; exit; }
user permissions using has read
permission
query against information_schema.
select table_name, table_type information_schema.tables
you can use columns table name + data types columns etc.
select table_schema, table_name, column_name, data_type, character_maximum_length information_schema.columns