Esempio n. 1
0
 private function __construct($host, $user, $password, $dbname, $type, $dbConnectType = 'pdo')
 {
     if (!extension_loaded($dbConnectType)) {
         header('Content-Type:text/html; charset=utf-8');
         die('没有' . $dbConnectType . '数据库扩展!');
     }
     self::$dbConnectType = $dbConnectType;
     //不同数据库类型连接
     switch ($dbConnectType) {
         case 'mysql':
             $db = new Db\MySQL();
             break;
         case 'mysqli':
             $db = new Db\MySQLi();
             break;
         case 'pdo':
             $db = new Db\PDO();
             break;
         default:
             $db = new Db\MySQLi();
     }
     self::$db[$type] = $db->connect($host, $user, $password, $dbname);
 }