/** * Singleton for database connections * * This method is going to verify if there's an existing instance * of a database object and if so will return it. * * @param string $name The name of the instantiation (namespace emulation) * This parameter is optional and is defaulted to 'default' * * @return PDO A new PDO object or an existing PDO object */ protected static function factory($name = 'default') { if (!isset(self::$instance[$name])) { $configs = Frapi_Internal::getCachedDbConfig(); self::$instance[$name] = new PDO('mysql:dbname=' . $configs['db_database'] . ';host=' . $configs['db_hostname'], $configs['db_username'], $configs['db_password'], array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\'')); } return self::$instance[$name]; }
/** * Singleton for database connections * * This method is going to verify if there's an existing instance * of a database object and if so will return it. * * @param string $name The name of the instantiation (namespace emulation) * This parameter is optional and is defaulted to 'default' * * @return PDO A new PDO object or an existing PDO object */ protected static function factory($name = 'default') { if (!isset(self::$instance[$name])) { $configs = Frapi_Internal::getCachedDbConfig(); self::$instance[$name] = new PDO('mysql:dbname=' . $configs['db_database'] . ';host=' . $configs['db_hostname'], $configs['db_username'], $configs['db_password']); } return self::$instance[$name]; }
/** * Singleton for database connections * * This method is going to verify if there's an existing instance * of a database object and if so will return it. * * @param string $name The name of the instantiation (namespace emulation) * This parameter is optional and is defaulted to 'default' * * @return PDO A new PDO object or an existing PDO object */ protected static function factory($name = 'default') { if (!isset(self::$instance[$name])) { $configs = Frapi_Internal::getCachedDbConfig(); $dsn = self::buildDsn($configs); // I iz not happy with this. We already have a switch // for the dsn in the "buildDsn" method... if (isset($configs['db_engine']) && in_array($configs['db_engine'], array('pgsql'))) { // DSN that have the user/pass implicitely defined. self::$instance[$name] = new PDO($dsn); } else { // Other dsns like mysql, mssql, etc. self::$instance[$name] = new PDO($dsn, $configs['db_username'], $configs['db_password']); } } return self::$instance[$name]; }
protected function _initApiUrl() { $int = Frapi_Internal::getCachedDbConfig(); Frapi_Internal::$_hash = isset($int['api_url']) ? hash('sha1', $int['api_url']) : false; }