本文整理匯總了PHP中DatabaseCompatibilityUtil::getMaxVarCharLength方法的典型用法代碼示例。如果您正苦於以下問題:PHP DatabaseCompatibilityUtil::getMaxVarCharLength方法的具體用法?PHP DatabaseCompatibilityUtil::getMaxVarCharLength怎麽用?PHP DatabaseCompatibilityUtil::getMaxVarCharLength使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DatabaseCompatibilityUtil
的用法示例。
在下文中一共展示了DatabaseCompatibilityUtil::getMaxVarCharLength方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: __construct
public function __construct($modelClassName, $attributeName)
{
parent::__construct($modelClassName, $attributeName);
assert('is_string($attributeName)');
$this->maxLength = DatabaseCompatibilityUtil::getMaxVarCharLength();
$this->messageCountData[static::EMAIL_TOO_LONG] = 0;
}
示例2: sanitizeValue
/**
* Given a value, resolve that the value is a correctly formatted url. If not, an
* InvalidValueToSanitizeException is thrown.
* @param mixed $value
* @return sanitized value
* @throws InvalidValueToSanitizeException
*/
public function sanitizeValue($value)
{
if ($value == null) {
return $value;
}
$maxLength = DatabaseCompatibilityUtil::getMaxVarCharLength();
if (false === ($validatedUrl = $this->resolveValidatedUrl($value))) {
throw new InvalidValueToSanitizeException(Zurmo::t('ImportModule', 'Invalid url format.'));
}
if (strlen($validatedUrl) > $maxLength) {
throw new InvalidValueToSanitizeException(Zurmo::t('ImportModule', 'URL was too long.'));
}
return $validatedUrl;
}
示例3: sanitizeValue
/**
* Given a value, resolve that the value is a correctly formatted email address. If not, an
* InvalidValueToSanitizeException is thrown.
* @param mixed $value
* @return sanitized value
* @throws InvalidValueToSanitizeException
*/
public function sanitizeValue($value)
{
assert('$this->mappingRuleData == null');
if ($value == null) {
return $value;
}
$maximumLength = DatabaseCompatibilityUtil::getMaxVarCharLength();
if (false === ($validatedEmail = $this->resolveValidatedEmail($value))) {
throw new InvalidValueToSanitizeException(Zurmo::t('ImportModule', 'Invalid email format.'));
}
if (strlen($validatedEmail) > $maximumLength) {
throw new InvalidValueToSanitizeException(Zurmo::t('ImportModule', 'Email was too long.'));
}
return $value;
}
示例4: sanitizeValue
/**
* Given a value, resolve that the value is a correctly formatted email address. If not, an
* InvalidValueToSanitizeException is thrown.
* @param string $modelClassName
* @param string $attributeName
* @param mixed $value
* @param array $mappingRuleData
*/
public static function sanitizeValue($modelClassName, $attributeName, $value, $mappingRuleData)
{
assert('is_string($modelClassName)');
assert('is_string($attributeName)');
assert('$mappingRuleData == null');
if ($value == null) {
return $value;
}
$maxLength = DatabaseCompatibilityUtil::getMaxVarCharLength();
$validator = new CEmailValidator();
$validatedEmail = $validator->validateValue($value);
if ($validatedEmail === false) {
throw new InvalidValueToSanitizeException(Zurmo::t('ImportModule', 'Invalid email format.'));
}
if (strlen($validatedEmail) > $maxLength) {
throw new InvalidValueToSanitizeException(Zurmo::t('ImportModule', 'Email was too long.'));
}
return $value;
}
示例5: testGetMaxVarCharLength
public function testGetMaxVarCharLength()
{
$this->assertEquals(255, DatabaseCompatibilityUtil::getMaxVarCharLength());
}