Exemple #1
0
 static function setupDB($dbhost, $dbuser, $dbpass, $dbname, $servers)
 {
     global $config;
     $config['db']['database_' . $dbname] = "mysqli://{$dbuser}:{$dbpass}@{$dbhost}/{$dbname}";
     $config['db']['ini_' . $dbname] = INSTALLDIR . '/classes/statusnet.ini';
     $config['db']['table_status_network'] = $dbname;
     self::$cache = new Memcache();
     if (is_array($servers)) {
         foreach ($servers as $server) {
             self::$cache->addServer($server);
         }
     } else {
         self::$cache->addServer($servers);
     }
     self::$base = $dbname;
 }
 /**
  * @param string $dbhost
  * @param string $dbuser
  * @param string $dbpass
  * @param string $dbname
  * @param array $servers memcached servers to use for caching config info
  */
 static function setupDB($dbhost, $dbuser, $dbpass, $dbname, $servers)
 {
     global $config;
     $config['db']['database_' . $dbname] = "mysqli://{$dbuser}:{$dbpass}@{$dbhost}/{$dbname}";
     $config['db']['ini_' . $dbname] = INSTALLDIR . '/classes/status_network.ini';
     $config['db']['table_status_network'] = $dbname;
     if (class_exists('Memcache')) {
         self::$cache = new Memcache();
         // If we're a parent command-line process we need
         // to be able to close out the connection after
         // forking, so disable persistence.
         //
         // We'll turn it back on again the second time
         // through which will either be in a child process,
         // or a single-process script which is switching
         // configurations.
         $persist = php_sapi_name() != 'cli' || self::$cacheInitialized;
         if (is_array($servers)) {
             foreach ($servers as $server) {
                 self::$cache->addServer($server, 11211, $persist);
             }
         } else {
             self::$cache->addServer($servers, 11211, $persist);
         }
         self::$cacheInitialized = true;
     }
     self::$base = $dbname;
 }