本文整理汇总了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());
}