Example #1
0
 public static function getInstance($dataType)
 {
     if (!isset(self::$connections[$dataType])) {
         try {
             $connection = new Mongo(Config::item('env.mongodb.server'), Config::item('env.mongodb.option'));
         } catch (MongoConnectionException $e) {
             $connection = new BlackHole();
             return self::$connections[$dataType] = $connection;
         }
         self::$connections[$dataType] = $connection->selectDB('chaoge')->selectCollection($dataType);
         self::$connections[$dataType]->setSlaveOkay();
     }
     return self::$connections[$dataType];
 }