这个问题一直延续到我先前的以下职位:here。
由于没有编辑你原来的职位,就无法再次抽出密码,因此,我正在开一个新职位。 并且,这还包含有PHP代码。
我写了两门,一是开放和关闭数据库,二是提供各种可再利用的职能,供亚洲开发银行使用。
下面是我关于连接班的PHP代码:
<?php
/**
* DBConnection Base Class Definition
*/
/* Include dependency */
require_once("configdbconfig.php");
abstract class dbconnection
{
var $conn;
//Opens connection for a MySQL DB
abstract function OpenConnection()
{
$conn = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD)
or die($this->ShowError(mysql_error()));
mysql_select_db(DB_NAME) or die ($this->ShowError("Connection to MySQL Database Failed. "));
}
//Closes connection for a MySQL DB
abstract function CloseConnection()
{
try
{
mysql_close($conn);
}
catch(exception $ex)
{
$this->ShowError($ex);
}
}
protected function ShowError($err)
{
echo "<script>alert( Error: +". $err .");</script>";
}
}
?>
The file included in the abovecode:
<?php
//Modify constants with data needed to access your own database
define( DB_HOST , localhost:3306 );
define( DB_NAME , MyStore );
define( DB_USER , super );
define( DB_PASSWORD , **** );
?>
下面是我关于抽象类别和接口的询问(续我先前的以下职位):
(1) Can a connection class be abstract? Are the methods written correctly?
(2) Instead of making the second code a file "dbconfig.php", will it be good to make an Interface for it?