mirror of
https://github.com/yiisoft/yii.git
synced 2026-03-22 16:06:53 +01:00
better regex to check that fieldnames follow PHP naming rules
This commit is contained in:
@@ -144,7 +144,7 @@ class ModelCode extends CCodeModel
|
||||
|
||||
/*
|
||||
* Check that all database field names conform to PHP variable naming rules
|
||||
* For example mysql allows field name like "2011aa", but PHP does not allow variable liek "$model->2011aa"
|
||||
* For example mysql allows field name like "2011aa", but PHP does not allow variable like "$model->2011aa"
|
||||
* @param CDbTableSchema $table the table schema object
|
||||
* @return string the invalid table column name. Null if no error.
|
||||
*/
|
||||
@@ -152,7 +152,7 @@ class ModelCode extends CCodeModel
|
||||
{
|
||||
foreach($table->columns as $column)
|
||||
{
|
||||
if(!preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/',$column->name))
|
||||
if(!preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/',$column->name))
|
||||
return $table->name.'.'.$column->name;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user