/** * Construction de la connexion * @todo prendre en charge les options spécifiques au driver */ public function __construct($pProfil) { parent::__construct($pProfil); $this->_autoCommitMode = self::OCI_AUTO_COMMIT; $parts = $this->_profil->getConnectionStringParts(); $funcName = $this->_profil->getOption(CopixDBProfile::PERSISTENT) ? 'oci_pconnect' : 'oci_connect'; if (($this->_ct = $funcName($this->_profil->getUser(), $this->_profil->getPassword(), $parts['dbname'], isset($parts['charset']) ? $parts['charset'] : null)) === false) { throw new CopixDBException('Impossible de se connecter avec le profil ' . $this->_profil->getName() . '.'); } // Récupère la longueur par défuat if (isset($parts['default_bind_length']) && is_numeric($parts['default_bind_length'])) { $this->_defaultBindLength = intval($parts['default_bind_length']); } // Récupère le type de paramètre par défaut switch (isset($parts['default_bind_type']) ? strtolower($parts['default_bind_type']) : null) { case 'db_string': case 'string': $this->_defaultBindType = CopixDBQueryParam::DB_STRING; break; case 'db_int': case 'int': $this->_defaultBindType = CopixDBQueryParam::DB_INT; break; } $this->_prepareEnvironment(); }
/** * Constructeur * @param CopixDBProfil $pProfil le profil de connexion à utiliser */ public function __construct($pProfil) { parent::__construct($pProfil); try { $this->_pdo = new PDO(substr($pProfil->getConnectionString(), 4), $pProfil->getUser(), $pProfil->getPassword(), $pProfil->getOptions()); } catch (PDOException $e) { throw new CopixDBException($e->getMessage()); } }
/** * Construction de la connexion * @todo prendre en charge les options spécifiques au driver * @param CopixDBProfile $pProfil le profil de connexion à utiliser pour se connecter à la base de donées. */ public function __construct($pProfil) { parent::__construct($pProfil); $parts = $this->_profil->getConnectionStringParts(); $parts['host'] = isset($parts['host']) ? $parts['host'] : "localhost"; if (!($this->_ct = mysql_connect($parts['host'], $this->_profil->getUser(), $this->_profil->getPassword(), true))) { throw new CopixDBException(mysql_error()); } if (!mysql_select_db($parts['dbname'], $this->_ct)) { throw new CopixDBException(mysql_error($this->_ct)); } }