odbc_tables
(PHP 4, PHP 5, PHP 7, PHP 8)
odbc_tables — Get the list of table names stored in a specific data source
說明
resource
$odbc
,?string
$catalog
= null
,?string
$schema
= null
,?string
$table
= null
,?string
$types
= null
): resource|false
Lists all tables in the requested range.
To support enumeration of qualifiers, owners, and table types,
the following special semantics for the
catalog
, schema
,
table
, and
table_type
are available:
-
If
catalog
is a single percent character (%) andschema
andtable
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.) -
If
schema
is a single percent character (%) andcatalog
andtable
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.) -
If
table_type
is a single percent character (%) andcatalog
,schema
andtable
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.)
參數
-
odbc
-
ODBC 連線識別符號,詳見 odbc_connect()。
-
catalog
-
The catalog ('qualifier' in ODBC 2 parlance).
-
schema
-
The schema ('owner' in ODBC 2 parlance). 此參數接受下列查詢模式:
%
來匹配零到多個字元,_
來匹配單個字元。 -
table
-
The name. 此參數接受下列查詢模式:
%
來匹配零到多個字元,_
來匹配單個字元。 -
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'
orTABLE, 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
或者在失敗時返回 false
.
The result set has the following columns:
TABLE_CAT
TABLE_SCHEM
TABLE_NAME
TABLE_TYPE
REMARKS
The result set is ordered by TABLE_TYPE
, TABLE_CAT
,
TABLE_SCHEM
and TABLE_NAME
.
更新日誌
版本 | 說明 |
---|---|
8.0.0 |
schema , table and types
are now nullable.
|
範例
示例 #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
}
?>
以上例程的輸出類似於:
Array ( [TABLE_CAT] => SalesOrders [TABLE_SCHEM] => dbo [TABLE_NAME] => Orders [TABLE_TYPE] => TABLE [REMARKS] => )
參見
- odbc_tableprivileges() - Lists tables and the privileges associated with each table
- odbc_columns() - Lists the column names in specified tables
- odbc_specialcolumns() - Retrieves special columns
- odbc_statistics() - Retrieve statistics about a table
- odbc_procedures() - Get the list of procedures stored in a specific data source