/** * 不是单例了 * 只是为了用最少次数去链接数据库 * Model::singleton() * @param string $db_group 数据库配置文件 */ public static function singleton($db_group = 'default') { //当不存在对象或者启用新的数据库时重新连库 if (empty(self::$connection_arr[$db_group])) { self::$singleton = new self($db_group); self::$connection_arr[$db_group] = self::$singleton; } else { self::$singleton = self::$connection_arr[$db_group]; } return self::$singleton; }
public function __construct() { $this->db = Model::singleton('default'); }