(PHP 4, PHP 5, PHP 7)
odbc_tables — Get the list of table names stored in a specific data source
$connection_id
[, string $catalog
[, string $schema
[, string $name
[, string $types
]]]] ) : resource|falseLists all tables in the requested range.
To support enumeration of qualifiers, owners, and table types,
the following special semantics for the
catalog, schema,
name, and
table_type are available:
catalog is a single percent
character (%) and schema and
name are empty strings, then the result
set contains a list of valid qualifiers for the data
source. (All columns except the TABLE_QUALIFIER column contain
NULLs.)
schema is a single percent character
(%) and catalog and
name are empty strings, then the result
set contains a list of valid owners for the data source. (All
columns except the TABLE_OWNER column contain
NULLs.)
table_type is a single percent
character (%) and catalog,
schema and name
are empty strings, then the result set contains a list of
valid table types for the data source. (All columns except the
TABLE_TYPE column contain NULLs.)
connection_idEine ODBC-Verbindungsressource, siehe odbc_connect() für Details.
catalogDer Katalog ('Kennzeichner' in ODBC 2 Terminologie).
schema
Das Schema ('Besitzer' in ODBC 2 Terminologie).
Dieser Parameter akzeptiert die
folgenden Suchmuster: % für 0 oder mehr Zeichen und _
für genau ein beliebiges Zeichen.
name
The name.
Dieser Parameter akzeptiert die
folgenden Suchmuster: % für 0 oder mehr Zeichen und _
für genau ein beliebiges Zeichen.
types
If table_type is not an empty string, it
must contain a list of comma-separated values for the types of
interest; each value may be enclosed in single quotes (') or
unquoted. For example, 'TABLE','VIEW' or TABLE, VIEW. If the
data source does not support a specified table type,
odbc_tables() does not return any results for
that type.
Returns an ODBC result identifier containing the information
Im Fehlerfall wird FALSE zurückgegeben..
The result set has the following columns:
TABLE_CATTABLE_SCHEMTABLE_NAMETABLE_TYPEREMARKS
The result set is ordered by TABLE_TYPE, TABLE_CAT,
TABLE_SCHEM and TABLE_NAME.
Beispiel #1 List Tables in a Catalog
<?php
$conn = odbc_connect($dsn, $user, $pass);
$tables = odbc_tables($conn, 'SalesOrders', 'dbo', '%', 'TABLE');
while (($row = odbc_fetch_array($tables))) {
print_r($row);
break; // further rows omitted for brevity
}
?>
Das oben gezeigte Beispiel erzeugt eine ähnliche Ausgabe wie:
Array
(
[TABLE_CAT] => SalesOrders
[TABLE_SCHEM] => dbo
[TABLE_NAME] => Orders
[TABLE_TYPE] => TABLE
[REMARKS] =>
)