Example #1
0
 /**
  * @param \Realboard\Component\Database\DBInstance\ConfigInterface $config
  */
 public function __construct(ConfigInterface $config)
 {
     $this->config = $config;
     $this->error = $config->getError();
     if (!in_array($config->getType(), $config->getAvailableDrivers())) {
         $config->getError()->setMessage(sprintf('%s driver is not available', ucfirst($config->getType())));
         return $this;
     }
     try {
         $this->connection = new \PDO($config->getDsn(), $config->getUser(), $config->getPass(), $config->getAttr());
     } catch (\PDOException $e) {
         $config->getError()->setMessage($e->getMessage());
     } catch (\Exception $e) {
         $config->getError()->setMessage($e->getMessage());
     }
 }