mysql_db_name

2009-06-23 09:25 / no comment / 22 views /

(PHP 4, PHP 5)获取数据库名称

声明

string _db_name ( resource $result , int $row [, mixed $field ] )
在mysql_list_dbs()的返回结果中检索数据库名。

参数

result
函数mysql_list_dbs()的返回结果。

row
结果的索引行。从第0行开始。

field
指定字段名,可选参数。

返回值

如果成功,则返回数据库名称;如果失败,则返回False。

例子

Example #1 mysql_db_name() example
<?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++; }
?>

注意

为了向后兼容,可能会使用下面这个别名:mysql_dbname()。

同样请看

mysql_list_dbs() – 列出MySQL服务器上可用的数据库
mysql_tablename() – 获得表名

Related Posts

  1. mysql_connect
  2. PHP中的MySQL函数
  3. mysql_num_rows
  4. mysql_db_query
  5. mysql_close
  6. mysql_data_seek
  7. mysql_create_db
  8. mysql_client_encoding
  9. mysql_affected_rows
  10. mysql_drop_db

Tags: .

Get a Trackback link

No Comments Yet

You can be the first to comment!

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>