日期:2014-05-17  浏览次数:20599 次

Yii框架更改数据类型
之前数据库有个字段是数值型,我用YII的工具GII把它生成,model,conttroler,view等层。后来由于项需求,要把数值改为字符串,于是我就把数据库的数值型改为字符型(char型)。然后把model层的 rules()方法下的数组:array('AA,BB, ', 'numerical'),

改为:

array('AA,BB','length','max'=>20),

最后我输入字符提效数据时,出现如下的错误:

CDbException
列名必须是一个字符串或者数组 

D:\web_root\rd1039b\framework\db\schema\CDbCommandBuilder.php(701)

689             }
690             if(count($values)===1)
691             {
692                 $entries=array();
693                 foreach($values[0] as $name=>$value)
694                     $entries[]=$prefix.$table->columns[$name]->rawName.($value===null?' IS NULL':'='.$value);
695                 return implode(' AND ',$entries);
696             }
697 
698             return $this->createCompositeInCondition($table,$values,$prefix);
699         }
700         else
701             throw new CDbException(Yii::t('yii','Column name must be either a string or an array.'));
702     }
......
.......
......
.....
......
CActiveRecord->save() 
249             }
250             
251                 
252                 if (Yii::app()->user->ROLE==STUDY_USER_ROLE_PI){
253                     $model->ENTRY2WHO= Yii::app()->user->USERNAME;
254                         if ($model-> save())
255                         {
256                             if($SORT!=3){
257                             $this->ToDo($Name,$MH1,$keyid);
258                             }
259                             else
.........