当前位置: 首页>>代码示例>>PHP>>正文


PHP Field::type方法代码示例

本文整理汇总了PHP中Field::type方法的典型用法代码示例。如果您正苦于以下问题:PHP Field::type方法的具体用法?PHP Field::type怎么用?PHP Field::type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Field的用法示例。


在下文中一共展示了Field::type方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: alterField

 function alterField(\Field $field, $add = false)
 {
     $q = $this->db->dsql()->expr('alter table [al_table] add [field_name] [type_expr]');
     $q->setCustom('al_table', $this->table);
     $q->setCustom('field_name', $x = $field->actual_field ?: $field->short_name);
     $q->setCustom('type_expr', $this->db->dsql()->expr($this->resolveFieldType($field->type())));
     $q->execute();
 }
开发者ID:xavocvijay,项目名称:atkschool,代码行数:8,代码来源:AutoCreator.php

示例2: mapFieldType

 /**
  * Map field types Model Field --> DB field
  *
  * @param Field $field
  *
  * @return string
  */
 protected function mapFieldType(\Field $field)
 {
     $type = $field->type();
     // try to find mapping
     // if not found, then fall back to default type or model field type
     if (isset($this->mapping[$type])) {
         $db_type = $this->mapping[$type];
     } else {
         $db_type = $this->default_type ?: $type;
     }
     // if no DB type found, then throw exception
     if (!$db_type) {
         throw $this->exception('No field type mapping found')->addMoreInfo('Model field type', $type);
     }
     // replace by template if any
     // template can be like varchar({length|255}) - $field->length() or $field->length or 255
     preg_replace_callback('/{([^{]*?)}/i', function ($matches) use($field, &$db_type) {
         $vars = explode('|', $matches[1]);
         $vars = array_map('trim', $vars);
         for ($i = 0; $i < count($vars), $v = $vars[$i]; $i++) {
             if (method_exists($field, $v) && @$field->{$v}()) {
                 // try to get from field method (surpress warnings because of setterGetter methods)
                 $db_type = str_replace($matches[0], $field->{$v}(), $db_type);
                 break;
             } elseif (property_exists($field, $v) && $field->{$v}) {
                 // try to get from field property
                 $db_type = str_replace($matches[0], $field->{$v}, $db_type);
                 break;
             } elseif (is_numeric($v)) {
                 // simply numeric constant
                 $db_type = str_replace($matches[0], $v, $db_type);
                 break;
             } elseif ($i == count($vars) - 1) {
                 // if last variant, then simply use that as constant
                 $db_type = str_replace($matches[0], $v, $db_type);
                 break;
             }
         }
     }, $db_type);
     return $db_type;
 }
开发者ID:xepan,项目名称:xepan,代码行数:48,代码来源:Abstract.php

示例3: getFieldType

 /**
  * Returns form field type associated with model field.
  *
  * Redefine this method to add special handling of your own fields.
  *
  * @param Field $field
  *
  * @return string
  */
 public function getFieldType($field)
 {
     // default form field type
     $type = 'Line';
     // try to find associated form field type
     if (isset($this->type_associations[$field->type()])) {
         $type = $this->type_associations[$field->type()];
     }
     if ($field instanceof Field_Reference) {
         $type = 'DropDown';
     }
     // if form field type explicitly set in model
     if ($field->display()) {
         $tmp = $field->display();
         if (is_array($tmp)) {
             $tmp = $tmp['form'];
         }
         if ($tmp) {
             $type = $tmp;
         }
     }
     return $type;
 }
开发者ID:atk4,项目名称:atk4,代码行数:32,代码来源:MVCForm.php

示例4: getFieldType

 /**
  * Returns grid column type associated with model field.
  *
  * Redefine this method to add special handling of your own fields.
  *
  * @param Field $field
  *
  * @return string
  */
 public function getFieldType($field)
 {
     // default column type
     $type = $field->type();
     // try to find associated form field type
     if (isset($this->type_associations[$type])) {
         $type = $this->type_associations[$type];
     }
     if ($type == 'text' && $field->allowHtml()) {
         $type = 'html';
     }
     // if grid column type/formatter explicitly set in model
     if ($field->display()) {
         // @todo this is wrong and obsolete, as hasOne uses display for way different purpose
         $tmp = $field->display();
         if (is_array($tmp)) {
             $tmp = $tmp['grid'];
         }
         if ($tmp) {
             $type = $tmp;
         }
     }
     return $type;
 }
开发者ID:atk4,项目名称:atk4,代码行数:33,代码来源:MVCGrid.php


注:本文中的Field::type方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。