當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。