I think it's better this way...
<?php
function sql_list_dbs($link) {
$result = mysql_query('SHOW DATABASES;', $link);
while( $data = mysql_fetch_row($result) ) {
$array[] = $data[0];
}
return $array;
}
?>
![]() | mysql_list_dbs说明resource mysql_list_dbs ( [resource link_identifier] )mysql_list_dbs() 将返回一个结果指针,包含了当前 MySQL 进程中所有可用的数据库。用 mysql_tablename() 函数来遍历此结果指针,或者任何使用结果表的函数,例如 mysql_fetch_array()。
为向下兼容仍然可以使用 mysql_listdbs(),但反对这样做。 参见 mysql_db_name()。 ![]()
vladson at pc-labs dot info
06-Jun-2005 09:58
I think it's better this way...
fred at surleau dot com
17-Mar-2001 05:07
[Editor's Note: mysql_db_name(), mysql_dbname() and mysql_tablename() are all aliases for mysql_result() and should behave in exactly the same fashion. --zak@php.net]
| ![]() | |