<?php
//ez_Sql数据库类,
//可能还需要更改ez_sql_mysql.php中的port端口值
//ez_SQL的引用路径,修改
include_once 'shared/ez_sql_core.php';
include_once 'mysql/ez_sql_mysql.php';
class myDb{
private static $db;
private static $instance=null;
/**
* Description:私有化构造函数,防止外界实例化对象
*/
private function __construct()
{
//修改连接数据库的账号、密码
$db_info = array(
'db_User' => 'root',
'db_Password' => '412724',
'db_Name' => 'hellosql',
'db_Host' => 'localhost',
'coding' => 'utf8'
);
self::$db = new ezSQL_mysql($db_info['db_User'], $db_info['db_Password'], $db_info['db_Name'], $db_info['db_Host'],$db_info['coding']);
}
/**
* Description:私有化克隆函数,防止外界克隆对象
*/
private function __clone()
{
}
/**
* Description:静态方法,单例访问统一入口
* @return Singleton:返回应用中的唯一对象实例
*/
public static function getInstance()
{
if (self::$instance == null)
{
self::$instance = new myDb;
}
return self::$instance;
}
public function getDb(){
return self::$db;
}
}
?>
ez_SQL 单例
最新推荐文章于 2024-03-21 20:45:43 发布