Beispiel #1
0
 /**
  * Get column
  *
  * @param  string $columnName
  * @param  string $table
  * @param  string $schema
  * @return Object\ColumnObject
  */
 public function getColumn($columnName, $table, $schema = null)
 {
     if ($schema === null) {
         $schema = $this->defaultSchema;
     }
     $this->loadColumnData($table, $schema);
     if (!isset($this->data['columns'][$schema][$table][$columnName])) {
         throw new \Exception('A column by that name was not found.');
     }
     $info = $this->data['columns'][$schema][$table][$columnName];
     $column = new Object\ColumnObject($columnName, $table, $schema);
     $props = array('ordinal_position', 'column_default', 'is_nullable', 'data_type', 'character_maximum_length', 'character_octet_length', 'numeric_precision', 'numeric_scale', 'numeric_unsigned', 'erratas');
     foreach ($props as $prop) {
         if (isset($info[$prop])) {
             $column->{'set' . str_replace('_', '', $prop)}($info[$prop]);
         }
     }
     $column->setOrdinalPosition($info['ordinal_position']);
     $column->setColumnDefault($info['column_default']);
     $column->setIsNullable($info['is_nullable']);
     $column->setDataType($info['data_type']);
     $column->setCharacterMaximumLength($info['character_maximum_length']);
     $column->setCharacterOctetLength($info['character_octet_length']);
     $column->setNumericPrecision($info['numeric_precision']);
     $column->setNumericScale($info['numeric_scale']);
     $column->setNumericUnsigned($info['numeric_unsigned']);
     $column->setErratas($info['erratas']);
     return $column;
 }
Beispiel #2
0
 /**
  * Get column
  * 
  * @param  string $columnName
  * @param  string $table
  * @param  string $schema
  * @param  string $database
  * @return Object\ColumnObject 
  */
 public function getColumn($columnName, $table, $schema = null)
 {
     // set values for database & schema
     $database = $database ?: '__DEFAULT_DB__';
     if ($schema == null && $this->defaultSchema != null) {
         $schema = $this->defaultSchema;
     }
     if (!isset($this->data[$database][$schema]['columns'][$table][$columnName])) {
         $this->loadColumnData($table, $schema, $database);
     }
     if (!isset($this->data[$database][$schema]['columns'][$table][$columnName])) {
         throw new \Exception('A column by that name was not found.');
     }
     $columnInfo =& $this->data[$database][$schema]['columns'][$table][$columnName];
     $column = new Object\ColumnObject($columnName, $table, $schema);
     $column->setOrdinalPosition($columnInfo['ORDINAL_POSITION']);
     $column->setColumnDefault($columnInfo['COLUMN_DEFAULT']);
     $column->setIsNullable($columnInfo['IS_NULLABLE']);
     $column->setDataType($columnInfo['DATA_TYPE']);
     $column->setCharacterMaximumLength($columnInfo['CHARACTER_MAXIMUM_LENGTH']);
     $column->setCharacterOctetLength($columnInfo['CHARACTER_OCTET_LENGTH']);
     $column->setNumericPrecision($columnInfo['NUMERIC_PRECISION']);
     $column->setNumericScale($columnInfo['NUMERIC_SCALE']);
     return $column;
 }