Example #1
0
 /**
  * Create a new couch DB connection instance.
  *
  * Static method to create a new couch DB connection instance. This method
  * should be used to configure the connection for later use.
  *
  * The host and its port default to localhost:5984.
  *
  * Optionally the class name of the called class can be provided. By
  * default the better working "custom connection" connection handler is
  * instantiated and used. The stream based connection handler is slower and
  * might not work at all.
  *
  * @param string $host
  * @param int $port
  * @param string $username
  * @param string $password
  * @param string $called
  * @return void
  */
 public static function createInstance($host = '127.0.0.1', $port = 5984, $username = null, $password = null, $called = "phpillowCustomConnection")
 {
     // Prevent from reestablishing connection during one run, without
     // explicit cleanup before.
     if (self::$instance !== null) {
         throw new phpillowConnectionException('Connection already established.', array());
     }
     // // Deafult to custom connection, if root class has been called. This
     // // currently is the safer default.
     // if ( !$called )
     // {
     //     $called = 'phpillowCustomConnection';
     // }
     // Create connection and store it in static property to be accessible
     // by static getInstance() method.
     self::$instance = new $called($host, $port, $username, $password);
 }