Exemple #1
0
 /**
  * @return void
  */
 public function connect()
 {
     if (null === $this->connection) {
         try {
             $this->connection = new Connection($this->config->getDsn(), $this->config->get('user'), $this->config->get('password'), $this->config->get('driver_options'));
             $this->connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
             $this->connection->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
         } catch (PDOException $e) {
             throw new RuntimeException($e->getMessage(), static::EXCEPTION_CODE, $e);
         }
     }
 }
Exemple #2
0
 /**
  * @internal
  */
 protected function loadKeys()
 {
     if (!isset($this->keys)) {
         $this->keys = array();
         $sql = "SELECT TABLE_NAME AS `table_name`, COLUMN_NAME AS `column_name`, " . "REFERENCED_COLUMN_NAME AS `referenced_column_name`, REFERENCED_TABLE_NAME AS `referenced_table_name` " . "FROM information_schema.KEY_COLUMN_USAGE " . "WHERE TABLE_SCHEMA = DATABASE() " . "AND REFERENCED_TABLE_SCHEMA = DATABASE()";
         $result = $this->connection->query($sql);
         $result->setFetchMode(PDO::FETCH_ASSOC);
         foreach ($result as $row) {
             $this->keys[] = $row;
         }
     }
     return $this->keys;
 }