如何更改 Yii 用户和权限中的数据类型?
How can I change the data type in Yii user and rights?
我是Yiibie,我使用的是Yii用户和权限扩展。我的问题是我想将名字、姓氏的数据类型从 varchar(50) 更改为 CHAR(50)。因为任何用户的名字都不能有数字。那么我该怎么做呢?
您可以在验证规则中使用 RegExp
在你的模型中
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
.....
array('firtsname, lastname', 'match' ,
'pattern'=> '/^[A-Za-z]+$/u',
'message'=> 'Firtsname and Lastname can contain only [a-zA-Z].'
),
....
);
}
我是Yiibie,我使用的是Yii用户和权限扩展。我的问题是我想将名字、姓氏的数据类型从 varchar(50) 更改为 CHAR(50)。因为任何用户的名字都不能有数字。那么我该怎么做呢?
您可以在验证规则中使用 RegExp
在你的模型中
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
.....
array('firtsname, lastname', 'match' ,
'pattern'=> '/^[A-Za-z]+$/u',
'message'=> 'Firtsname and Lastname can contain only [a-zA-Z].'
),
....
);
}