Exemple #1
0
 /**
  * Set database
  *
  * @param string $dbname
  * @return Adapter
  * @throws UnknownDatabaseException
  */
 public function setDatabase($dbname)
 {
     $this->config->setDatabase($dbname);
     if ($this->connection) {
         try {
             $this->query('USE ' . $this->quoter->quoteIdentifier($dbname));
         } catch (RuntimeException $exception) {
             $prevException = $exception->getPrevious();
             if (UnknownDatabaseException::isUnknownDatabase($prevException)) {
                 throw UnknownDatabaseException::createFromUnknownDatabase($dbname, $prevException);
             }
             throw $exception;
         }
     }
     return $this;
 }