Пример #1
0
 /**
  * Initialize the ReturnModel class
  */
 public function init()
 {
     try {
         parent::init();
     } catch (Exception $e) {
         throw new Exception('Une erreur est survenue durant le chargement du module: ' . $e->getMessage());
     }
     try {
         $pdo_options[\PDO::ATTR_ERRMODE] = \PDO::ERRMODE_EXCEPTION;
         $this->db = new \PDO('mysql:host=' . _HOST_ . ';dbname=' . _DATABASE_, _LOGIN_, _PASSWORD_, $pdo_options);
         $this->db->exec('SET NAMES utf8');
     } catch (Exception $e) {
         throw new Exception('Connexion à la base de données impossible: ' . $e->getMessage());
     }
 }
Пример #2
0
 /**
  * Initialize the DisplayModel class
  */
 public function init()
 {
     try {
         parent::init();
     } catch (Exception $e) {
         throw new Exception('Une erreur est survenue durant le chargement du module: ' . $e->getMessage());
     }
     try {
         $this->db = oci_connect(_LOGIN_, _PASSWORD_, _HOST_);
         if (!$this->db) {
             $e = oci_error();
             trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
         }
         //-------------------Ancienne connexion----------------------------
         /*
         $pdo_options[\PDO::ATTR_ERRMODE] = \PDO::ERRMODE_EXCEPTION;
         $this->db = new \PDO('mysql:host='._HOST_ .';dbname='._DATABASE_, _LOGIN_, _PASSWORD_, $pdo_options);
         $this->db->exec('SET NAMES utf8');
         */
         //-----------------------------------------------------------------
     } catch (Exception $e) {
         throw new Exception('Connexion à la base de données impossible: ' . $e->getMessage());
     }
 }