public static function fromXML(SimpleXMLElement $xml)
 {
     $th = new ConnectionParameters();
     if (empty($xml)) {
         return $th;
     }
     $th->setMaxConnections((string) $xml->numConnections);
     $th->setNumConnections((string) $xml->maxConnections);
     $th->setConnectionAcquisitionTimeout((string) $xml->connectionAcquisitionTimeout);
     $th->getInitialConnectionTimeout((string) $xml->initialConnectionTimeout);
     $th->getInitialConnectionTimeoutAttempts((string) $xml->initialConnectionTimeoutAttempts);
     return $th;
 }
예제 #2
0
 public static function fromXML(SimpleXMLElement $xml)
 {
     $th = new TargetHost();
     $th->setAuthentication(Authentication::fromXML($xml->authentication));
     $th->setUrl((string) $xml->url);
     $th->setSite((string) $xml->site);
     if ($xml->forwardProxy) {
         $th->setProxy(ForwardProxy::fromXML($xml->forwardProxy));
     }
     if ($xml->connectionParameters) {
         $th->setConnectionParameters(ConnectionParameters::fromXML($xml->connectionParameters));
     }
     return $th;
 }
예제 #3
0
파일: Database.php 프로젝트: dazarobbo/cola
 /**
  * Attempt to connect to the database. Does nothing if already connected.
  * @access public
  * @return static
  */
 public static function connect(ConnectionParameters $config)
 {
     //Not static
     $con = new self();
     switch (\strtolower(\trim($config->getDriver()))) {
         case 'sqlite':
             $con->Connection = new \PDO(\sprintf('sqlite:%s', $config->getHost()), $config->getUsername(), $config->getPassword(), $config->getOptions());
             break;
         default:
             $con->Connection = new \PDO(\sprintf('%s:host=%s;charset=%s;dbname=%s', $config->getDriver() ? $config->getDriver() : '', $config->getHost() ? $config->getHost() : '', $config->getCharset() ? $config->getCharset() : '', $config->getDatabaseName() ? $config->getDatabaseName() : ''), $config->getUsername(), $config->getPassword(), $config->getOptions());
             break;
     }
     return $con;
 }