예제 #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);
     }
 }
예제 #2
0
파일: SQLBind.php 프로젝트: byjg/anydataset
 /**
  * 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 ":_";
     }
 }
예제 #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;
 }
예제 #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);
 }