本文整理汇总了PHP中CModel::hasAttribute方法的典型用法代码示例。如果您正苦于以下问题:PHP CModel::hasAttribute方法的具体用法?PHP CModel::hasAttribute怎么用?PHP CModel::hasAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CModel
的用法示例。
在下文中一共展示了CModel::hasAttribute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validateAttribute
/**
* Validates the attribute of the object.
* @param CModel $object the object being validated
* @param string $attribute the attribute being validated
*/
protected function validateAttribute($object, $attribute)
{
if ($this->setOnEmpty && !$this->isEmpty($object->{$attribute})) {
return;
}
if (!$object->hasAttribute($this->translitAttribute)) {
throw new CException(Yii::t('yiiext', 'Active record "{class}" is trying to select an invalid column "{column}". Note, the column must exist in the table or be an expression with alias.', array('{class}' => get_class($object), '{column}' => $this->translitAttribute)));
}
$object->{$attribute} = self::latin($object->getAttribute($this->translitAttribute));
}
示例2: validateAttribute
/**
* Validates the attribute of the object.
* @param CModel $object the object being validated
* @param string $attribute the attribute being validated
*/
protected function validateAttribute($object, $attribute)
{
if ($this->setOnEmpty && !$this->isEmpty($object->{$attribute})) {
return;
}
if (!$object->hasAttribute($this->translitAttribute)) {
throw new CException(Yii::t('yiiext', 'Active record "{class}" is trying to select an invalid column "{column}". Note, the column must exist in the table or be an expression with alias.', array('{class}' => get_class($object), '{column}' => $this->translitAttribute)));
}
$object->{$attribute} = self::cyrillicToLatin($object->getAttribute($this->translitAttribute));
if ($this->toLower) {
$object->{$attribute} = strtolower($object->{$attribute});
}
//mb_
if ($this->replaceSlashes) {
$object->{$attribute} = preg_replace('#\\/#', '-', $object->{$attribute});
}
//mb_
if ($this->removeNonLatin) {
$object->{$attribute} = preg_replace('/[^A-Za-z0-9_\\-]/', '', $object->{$attribute});
}
}