Example #1
0
 /**
  *  get the dsn connection string that PDO will use to connect to the backend
  *  
  *  @link http://us3.php.net/manual/en/ref.pdo-sqlite.php   
  *  @since  10-18-10
  *  @param  string  $name the database name
  *  @param  string  $host the host
  *  @return string  the dsn         
  */
 protected function getDsn(MingoConfig $config)
 {
     // canary
     if (!$config->hasName()) {
         throw new InvalidArgumentException('no name specified');
     }
     //if
     // for sqlite: PRAGMA encoding = "UTF-8"; from http://sqlite.org/pragma.html only good on db creation
     // http://stackoverflow.com/questions/263056/how-to-change-character-encoding-of-a-pdo-sqlite-connection-in-php
     return sprintf('sqlite:%s', $config->getName());
 }
 public function createConfig()
 {
     $path = sys_get_temp_dir();
     if (mb_substr($path, -1) === DIRECTORY_SEPARATOR) {
         $path = mb_substr($path, 0, -1);
     }
     //if
     $name = sprintf('%s_lucene', join(DIRECTORY_SEPARATOR, array($path, md5(get_class($this) . microtime(true)))));
     $config = new MingoConfig($name, '', '', '', array());
     $config->setDebug(true);
     return $config;
 }
Example #3
0
 /**
  *  get the dsn connection string that PDO will use to connect to the backend
  *   
  *  @link http://us2.php.net/manual/en/ref.pdo-mysql.php
  *  @link http://us2.php.net/manual/en/ref.pdo-mysql.connection.php   
  *  @since  10-18-10
  *  @param  \MingoConfig  $config
  *  @return string  the dsn   
  */
 protected function getDsn(MingoConfig $config)
 {
     // canary...
     if (!$config->hasHost()) {
         throw new InvalidArgumentException('no host specified');
     }
     //if
     if (!$config->hasName()) {
         throw new InvalidArgumentException('no name specified');
     }
     //if
     // charset is actually ignored <5.3.6
     return sprintf('mysql:host=%s;dbname=%s;charset=%s', $config->getHost(), $config->getName(), $this->charset);
 }
Example #4
0
 /**
  *  do the actual connecting of the interface
  *
  *  @see  connect()   
  *  @return boolean
  */
 protected function _connect(MingoConfig $config)
 {
     // we need Zend Lucene in order to work...
     if (!class_exists('Zend_Search_Lucene', true)) {
         throw new UnexpectedValueException('"Zend_Search_Lucene" cannot be found, is the ZF path in the included paths?');
     }
     //if
     $path = $config->getName();
     // make sure path doesn't end with a slash...
     $path_last_char = mb_substr($path, -1);
     if ($path_last_char === DIRECTORY_SEPARATOR || $path_last_char === '/') {
         $path = mb_substr($path, 0, -1);
     }
     //if
     $this->setField('path', $path);
     return true;
 }
 /**
  *  get the dsn connection string that PDO will use to connect to the backend
  *   
  *  @since  10-18-10
  *  @param  \MingoConfig  $config
  *  @return string  the dsn   
  */
 protected function getDsn(MingoConfig $config)
 {
     // canary...
     if (!$config->hasHost()) {
         throw new InvalidArgumentException('no host specified');
     }
     //if
     if (!$config->hasName()) {
         throw new InvalidArgumentException('no name specified');
     }
     //if
     return sprintf('pgsql:dbname=%s;host=%s;port=%s', $config->getName(), $config->getHost(), $config->getPort(5432));
 }
Example #6
0
 public function createConfig()
 {
     $config = new MingoConfig('vagrant', 'localhost:3306', 'vagrant', 'vagrant', array());
     $config->setDebug(true);
     return $config;
 }