/**
  * @return void
  */
 private function importProperty()
 {
     if (!sizeof($this->ormProperty->getFields())) {
         // columnless properties are skipped
         return;
     }
     $columns = array_combine($this->ormProperty->getFields(), $this->ormProperty->getType()->getSqlTypes());
     foreach ($columns as $name => $dbType) {
         $this->dbTable->addColumn(new DBColumn($name, $this->dbTable, $dbType));
     }
     // now add constraints and indexes
     $this->importConstraints($this->ormProperty);
 }
 public function getTableInfo($table)
 {
     static $types = array('tinyint' => DataType::SMALLINT, 'smallint' => DataType::SMALLINT, 'int' => DataType::INTEGER, 'mediumint' => DataType::INTEGER, 'bigint' => DataType::BIGINT, 'double' => DataType::DOUBLE, 'decimal' => DataType::NUMERIC, 'char' => DataType::CHAR, 'varchar' => DataType::VARCHAR, 'text' => DataType::TEXT, 'tinytext' => DataType::TEXT, 'mediumtext' => DataType::TEXT, 'date' => DataType::DATE, 'time' => DataType::TIME, 'timestamp' => DataType::TIMESTAMP, 'datetime' => DataType::TIMESTAMP, 'set' => null, 'enum' => null, 'year' => null);
     try {
         $result = $this->queryRaw('SHOW COLUMNS FROM ' . $table);
     } catch (BaseException $e) {
         throw new ObjectNotFoundException("unknown table '{$table}'");
     }
     $table = new DBTable($table);
     while ($row = mysql_fetch_assoc($result)) {
         $name = strtolower($row['Field']);
         $matches = array();
         $info = array('type' => null, 'extra' => null);
         if (preg_match('~(\\w+)(\\((\\d+?)\\)){0,1}\\s*(\\w*)~', strtolower($row['Type']), $matches)) {
             $info['type'] = $matches[1];
             $info['size'] = $matches[3];
             $info['extra'] = $matches[4];
         }
         Assert::isTrue(array_key_exists($info['type'], $types), 'unknown type "' . $types[$info['type']] . '" found in column "' . $name . '"');
         if (empty($types[$info['type']])) {
             continue;
         }
         $column = DBColumn::create(DataType::create($types[$info['type']])->setUnsigned(strtolower($info['extra']) == 'unsigned')->setNull(strtolower($row['Null']) == 'yes'), $name)->setAutoincrement(strtolower($row['Extra']) == 'auto_increment')->setPrimaryKey(strtolower($row['Key']) == 'pri');
         if ($row['Default']) {
             $column->setDefault($row['Default']);
         }
         $table->addColumn($column);
     }
     return $table;
 }
 /**
  * @throws ObjectNotFoundException
  * @return DBTable
  **/
 public function getTableInfo($table)
 {
     static $types = array('time' => DataType::TIME, 'date' => DataType::DATE, 'timestamp' => DataType::TIMESTAMP, 'bool' => DataType::BOOLEAN, 'int2' => DataType::SMALLINT, 'int4' => DataType::INTEGER, 'int8' => DataType::BIGINT, 'numeric' => DataType::NUMERIC, 'float4' => DataType::REAL, 'float8' => DataType::DOUBLE, 'varchar' => DataType::VARCHAR, 'bpchar' => DataType::CHAR, 'text' => DataType::TEXT, 'bytea' => DataType::BINARY, 'ip4' => DataType::IP, 'inet' => DataType::IP, 'ip4r' => DataType::IP_RANGE, 'tsvector' => null, 'ltree' => null, 'hstore' => null);
     try {
         $res = pg_meta_data($this->link, $table);
     } catch (BaseException $e) {
         throw new ObjectNotFoundException("unknown table '{$table}'");
     }
     $table = new DBTable($table);
     foreach ($res as $name => $info) {
         Assert::isTrue(array_key_exists($info['type'], $types), 'unknown type "' . $types[$info['type']] . '" found in column "' . $name . '"');
         if (empty($types[$info['type']])) {
             continue;
         }
         $column = new DBColumn(DataType::create($types[$info['type']])->setNull(!$info['not null']), $name);
         $table->addColumn($column);
     }
     return $table;
 }