这是我的课:
class MySQLDB extends PDO{
private $_connection;
private static $_instance; //The single instance
private $_host = MYSQL_SERVER_NAME;
private $_username = MYSQL_SERVER_USERNAME;
private $_password = MYSQL_SERVER_PASSWORD;
private $_database = MYSQL_SERVER_DBNAME;
/*
Get an instance of the MySQLDB
@return Instance
*/
public static function getInstance() {
if(!self::$_instance) { // If no instance then make one
self::$_instance = new self();
}
return self::$_instance;
}
// Get PDO MySQL connection
public function getConnection() {
return $this->_connection;
}
public function __construct(){
try {
$this->_connection = …Run Code Online (Sandbox Code Playgroud)