예제 #1
0
 /**
  * Initialize the AddModel 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());
     }
 }