/** * * @param int $dbId * 数据连接编号 * @param boolean $newLink * 是否使用新连接[可选],默认值为false * @return \PDO * @throws \PDOException */ public static function getConn($dbId, $newLink = false) { if ($newLink || !isset(self::$conns[$dbId])) { $app = Application::getApp(); $dblist = $app->getAppConfig()->get('dblist', array()); if (!isset($dblist[$dbId])) { throw new \PDOException('dbId ' . $dbId . ' not found !'); } $dbConf = $dblist[$dbId]; self::$conns[$dbId] = new \PDO($dbConf['dsn'], $dbConf['username'], $dbConf['password'], $dbConf['options']); } return self::$conns[$dbId]; }
public static function getFs($fsId) { if (!isset(self::$fsArr[$fsId])) { $app = Application::getApp(); $fslist = $app->getAppConfig()->get('fslist', array()); if (!isset($fslist[$fsId])) { throw new FsException('fsId ' . $fsId . ' not found !'); } $fsConf = $fslist[$fsId]; $fsClass = __NAMESPACE__ . '\\fs\\' . $fsConf['type'] . 'Driver'; $fsObject = new $fsClass($fsConf['config']); if (!$fsObject instanceof FsInter) { throw new FsException('bad fs driver'); } self::$fsArr[$fsId] = $fsObject; } return self::$fsArr[$fsId]; }
/** * registers instantiated application in registry * @param Application $application */ public function register(Application $application) { $this->apps[$application->getApp()] = $application; }