(PHP 4, PHP 5)
mysql_db_name — 取得结果数据
取得 mysql_list_dbs() 调用所返回的数据库名。
如果成功则返回数据库名,失败返回 FALSE
。如果返回了 FALSE
,用
mysql_error() 来判断错误的种类。
Example #1 mysql_db_name() 例子
<?php
error_reporting(E_ALL);
$link = mysql_connect('dbhost', 'username', 'password');
$db_list = mysql_list_dbs($link);
$i = 0;
$cnt = mysql_num_rows($db_list);
while ($i < $cnt) {
echo mysql_db_name($db_list, $i) . "\n";
$i++;
}
?>
Note: Suggested alternatives
Use of this extension is discouraged. Instead, the MySQLi or PDO_MySQL extension should be used. See also MySQL: choosing an API for more information.
Alternatives to this function include:
- Query: SELECT DATABASE()
Note:
为了向下兼容,可以使用下列已废弃的别名: mysql_dbname()