本文整理匯總了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);
}
示例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());
}
}