示例#1
0
 /**
  * Get database field definition
  * @params pdoMap_Mapping_Metadata_Field Field to manage
  * @returns array of pdoMap_Mapping_Metadata_Field  
  * @throw pdoMap_Database_Fields_Exceptions_BadType                            
  */
 public function getMeta(pdoMap_Mapping_Metadata_Field $field)
 {
     if ($field->type != 'Integer') {
         throw new pdoMap_Database_Fields_Exceptions_BadType($field, 'Integer');
     }
     if (!$field->getOption('size')) {
         $field->setOption('size', self::DEFAULT_SIZE);
     }
     if (!in_array($field->getOption('size'), self::$SIZE_LIST)) {
         throw new pdoMap_Database_Fields_Exceptions_BadOption($field, 'size');
     }
     return array(pdoMap_Mapping_Metadata_Field::duplicate($field, pdoMap_Mapping_Metadata_Field::FIELD_TYPE_INT));
 }
示例#2
0
 /**
  * Duplicate a field and change some information
  */
 public static function duplicate(pdoMap_Mapping_Metadata_Field $field, $type = null, $name = null, $bind = null, $options = null)
 {
     $ret = new pdoMap_Mapping_Metadata_Field($field->name, $field->bind, $field->type, $field->getOptions());
     if (!is_null($type)) {
         $ret->type = $type;
     }
     if (!is_null($name)) {
         $ret->name = $name;
     }
     if (!is_null($bind)) {
         $ret->bind = $bind;
     }
     if (!is_null($options)) {
         foreach ($options as $key => $value) {
             $ret->setOption($key, $value);
         }
     }
     return $ret;
 }