コード例 #1
0
ファイル: DbalManager.php プロジェクト: Beanbiscuit/examples
 /**
  * Configures and then returns a data access object returned from a Driver.
  * 
  * @return \PDO
  * @throws DbalException
  */
 public function getDataObject()
 {
     $aConfig = $this->oConfig->get();
     if (isset($aConfig[Configuration::CONNECTION_KEY]) && isset($aConfig[Configuration::CONNECTION_KEY]['driver'])) {
         $oDriver = $this->oDriverFactory->getInstance($aConfig[Configuration::CONNECTION_KEY]['driver']);
         $oPDO = $oDriver->getDataAccessObject($this->oConfig);
         //Configure the error reporting level for PDO.
         $this->setErrorMode($oPDO);
         return $oPDO;
     } else {
         throw DbalException::invalidConfiguration('Cannot find driver in configurations.');
     }
 }