Beispiel #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);
     }
 }