public function __construct() { self::$conn = mysql_connect($this->mysql_host, $this->mysql_username, $this->mysql_password); if (!self::$conn) { die('Can\'t connect to database'); } mysql_select_db("{$this->mysql_database}"); }
/** * 数据库连接 */ public static function &getConn() { if (self::$conn == null) { $conn = new PDO(sprintf(Config::DB_LINK, DIR_ROOT), "charset=UTF-8"); if (IS_DEBUG) { $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } else { $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT); } self::$conn = $conn; } return self::$conn; }