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


PHP DbHelper::getTextualColumnTypeByContentLength方法代码示例

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


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

示例1: defineContentAttribute

 public function defineContentAttribute()
 {
     $maxLength = $this->getSettings()->maxLength;
     if (!$maxLength) {
         $columnType = ColumnType::Text;
     } else {
         $columnType = DbHelper::getTextualColumnTypeByContentLength($maxLength);
     }
     return array(AttributeType::String, 'column' => $columnType, 'maxLength' => $maxLength);
 }
开发者ID:kepler27,项目名称:FormBuilder-Craft-CMS,代码行数:10,代码来源:FormBuilder_PlainTextFieldType.php

示例2: defineContentAttribute

 /**
  * @inheritDoc IFieldType::defineContentAttribute()
  *
  * @return mixed
  */
 public function defineContentAttribute()
 {
     if ($this->multi) {
         $options = $this->getSettings()->options;
         // See how much data we could possibly be saving if everything was selected.
         $length = 0;
         foreach ($options as $option) {
             if (!empty($option['value'])) {
                 // +3 because it will be json encoded. Includes the surrounding quotes and comma.
                 $length += strlen($option['value']) + 3;
             }
         }
         if ($length) {
             // Add +2 for the outer brackets and -1 for the last comma.
             $length += 1;
             $columnType = DbHelper::getTextualColumnTypeByContentLength($length);
         } else {
             $columnType = ColumnType::Varchar;
         }
         return array(AttributeType::Mixed, 'column' => $columnType, 'default' => $this->getDefaultValue());
     } else {
         return array(AttributeType::String, 'column' => ColumnType::Varchar, 'maxLength' => 255, 'default' => $this->getDefaultValue());
     }
 }
开发者ID:jmstan,项目名称:craft-website,代码行数:29,代码来源:BaseOptionsFieldType.php


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