コード例 #1
0
ファイル: DBPDODriver.php プロジェクト: byjg/anydataset
 public function __construct(ConnectionManagement $connMngt, $strcnn, $preOptions, $postOptions)
 {
     $this->_connectionManagement = $connMngt;
     if (is_null($strcnn)) {
         if ($this->_connectionManagement->getFilePath() != "") {
             $strcnn = $this->_connectionManagement->getDriver() . ":" . $this->_connectionManagement->getFilePath();
         } else {
             $strcnn = $this->_connectionManagement->getDriver() . ":dbname=" . $this->_connectionManagement->getDatabase();
             if ($this->_connectionManagement->getExtraParam("unixsocket") != "") {
                 $strcnn .= ";unix_socket=" . $this->_connectionManagement->getExtraParam("unixsocket");
             } else {
                 $strcnn .= ";host=" . $this->_connectionManagement->getServer();
                 if ($this->_connectionManagement->getPort() != "") {
                     $strcnn .= ";port=" . $this->_connectionManagement->getPort();
                 }
             }
         }
     }
     // Create Connection
     $this->_db = new PDO($strcnn, $this->_connectionManagement->getUsername(), $this->_connectionManagement->getPassword(), (array) $preOptions);
     $this->_connectionManagement->setDriver($this->_db->getAttribute(PDO::ATTR_DRIVER_NAME));
     // Set Specific Attributes
     $this->_db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     $this->_db->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER);
     foreach ((array) $postOptions as $key => $value) {
         $this->_db->setAttribute($key, $value);
     }
 }
コード例 #2
0
ファイル: DBOci8Driver.php プロジェクト: byjg/anydataset
 /**
  * Ex.
  *
  *    oci8://username:password@host:1521/servicename?protocol=TCP&codepage=WE8MSWIN1252
  *
  * @param ConnectionManagement $connMngt
  * @throws DatabaseException
  */
 public function __construct($connMngt)
 {
     $this->_connectionManagement = $connMngt;
     $codePage = $this->_connectionManagement->getExtraParam("codepage");
     $codePage = $codePage == "" ? 'UTF8' : $codePage;
     $tns = DBOci8Driver::getTnsString($connMngt);
     $this->_conn = oci_connect($this->_connectionManagement->getUsername(), $this->_connectionManagement->getPassword(), $tns, $codePage);
     if (!$this->_conn) {
         $e = oci_error();
         throw new DatabaseException($e['message']);
     }
 }
コード例 #3
0
ファイル: MongoDBDriver.php プロジェクト: byjg/anydataset
 /**
  * Creates a new MongoDB connection. This class is managed from NoSqlDataset
  *
  * @param ConnectionManagement $connMngt
  * @param string $collection
  */
 public function __construct($connMngt, $collection)
 {
     $this->_connectionManagement = $connMngt;
     $hosts = $this->_connectionManagement->getServer();
     $port = $this->_connectionManagement->getPort() == '' ? 27017 : $this->_connectionManagement->getPort();
     $database = $this->_connectionManagement->getDatabase();
     $username = $this->_connectionManagement->getUsername();
     $password = $this->_connectionManagement->getPassword();
     if ($username != '' && $password != '') {
         $auth = array('username' => $username, 'password' => $password, 'connect' => 'true');
     } else {
         $auth = array('connect' => 'true');
     }
     $connecting_string = sprintf('mongodb://%s:%d', $hosts, $port);
     $this->_client = new MongoClient($connecting_string, $auth);
     $this->_db = new MongoDB($this->_client, $database);
     $this->setCollection($collection);
 }
コード例 #4
0
ファイル: DBSQLRelayDriver.php プロジェクト: byjg/anydataset
 public function __construct($connMngt)
 {
     $this->_connectionManagement = $connMngt;
     $this->_conn = sqlrcon_alloc($this->_connectionManagement->getServer(), $this->_connectionManagement->getPort(), $this->_connectionManagement->getExtraParam("unixsocket"), $this->_connectionManagement->getUsername(), $this->_connectionManagement->getPassword(), 0, 1);
     sqlrcon_autoCommitOn($this->_conn);
 }