예제 #1
0
 /**
  * ID of the component.
  *
  * @param   string  $id    ID of the component.
  * @return  mixed
  */
 public function reachId($id)
 {
     return Registry::get($id);
 }
예제 #2
0
파일: execute.php 프로젝트: jemdev/dbrm
 protected function _connect($aInfosCnx)
 {
     if (false === Registry::isRegistered('dbCnx')) {
         $dns = $aInfosCnx['pilote'];
         $dns .= ':host=' . $aInfosCnx['server'];
         $dns .= !empty($aInfosCnx['port']) ? ';port=' . $aInfosCnx['port'] : '';
         $dns .= ';dbname=' . $aInfosCnx['name'];
         $options = $aInfosCnx['pilote'] == 'mysql' ? array(\PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES UTF8;') : null;
         try {
             $this->_dbh = new \PDO($dns, $aInfosCnx['user'], $aInfosCnx['mdp'], $options);
             Registry::set('dbCnx', $this->_dbh);
             $this->_dbh->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
             $this->_bConnecte = true;
         } catch (\PDOException $p) {
             $this->_bConnecte = false;
             $this->_aDbErreurs[] = array('La connexion a échoué', 'Message : ' . $p->getMessage(), 'Trace : ' . $p->getTraceAsString());
         } catch (\Exception $e) {
             $this->_bConnecte = false;
             $this->_aDbErreurs[] = array('La connexion a échoué', 'Message : ' . $e->getMessage(), 'Trace : ' . $e->getTraceAsString());
         }
     } else {
         $this->_dbh = Registry::get('dbCnx');
         $this->_bConnecte = true;
     }
 }