Ejemplo n.º 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);
     }
 }
Ejemplo n.º 2
0
 /**
  * Each provider have your own model for pass parameter. This method define how each provider name define the parameters
  *
  * @param ConnectionManagement $connData
  * @return string
  */
 public static function getParamModel(ConnectionManagement $connData)
 {
     if ($connData->getExtraParam("parammodel") != "") {
         return $connData->getExtraParam("parammodel");
     } elseif ($connData->getDriver() == "sqlrelay") {
         return "?";
     } else {
         return ":_";
     }
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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);
 }