Example #1
0
 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);
     }
 }
Example #2
0
 /**
  * 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);
 }
Example #3
0
 /**
  *
  * @param ConnectionManagement $connMngt
  * @return string
  */
 public static function getTnsString($connMngt)
 {
     $protocol = $connMngt->getExtraParam("protocol");
     $protocol = $protocol == "" ? 'TCP' : $protocol;
     $port = $connMngt->getPort();
     $port = $port == "" ? 1521 : $port;
     $svcName = $connMngt->getDatabase();
     $host = $connMngt->getServer();
     $tns = "(DESCRIPTION = " . "\t(ADDRESS = (PROTOCOL = {$protocol})(HOST = {$host})(PORT = {$port})) " . "\t\t(CONNECT_DATA = (SERVICE_NAME = {$svcName})) " . ")";
     return $tns;
 }
Example #4
0
 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);
 }