better regex to check that fieldnames follow PHP naming rules

This commit is contained in:
mdomba
2011-04-27 07:45:15 +00:00
parent 54aec26f93
commit c5e9d7fbb6

View File

@@ -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;
}
}