(PHP 4, PHP 5)
mysql_drop_db — Drop (delete) a MySQL database
This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQL extension should be used. See also MySQL: choosing an API guide and related FAQ for more information. Alternatives to this function include:
$database_name
[, resource $link_identifier
= NULL
] )mysql_drop_db() attempts to drop (remove) an entire database from the server associated with the specified link identifier. This function is deprecated, it is preferable to use mysql_query() to issue an sql DROP DATABASE statement instead.
database_name
The name of the database that will be deleted.
link_identifier
MySQL 的連接識別符。如果沒有指定,預設使用最後被
mysql_connect() 打開的連接。如果沒有找到該連接,函式會嘗試呼叫
mysql_connect() 建立連接並使用它。如果發生意外,沒有找到連接或無法建立連接,系統發出
E_WARNING
級別的警告信息。
如果成功則回傳 TRUE
,失敗則回傳 FALSE
。
Example #1 mysql_drop_db() alternative example
<?php
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
$sql = 'DROP DATABASE my_db';
if (mysql_query($sql, $link)) {
echo "Database my_db was successfully dropped\n";
} else {
echo 'Error dropping database: ' . mysql_error() . "\n";
}
?>
This function will not be available if the MySQL extension was built against a MySQL 4.x client library.
Note:
為了保證向前相容,可以使用下面的別名,但不贊成使用它: mysql_dropdb()