您的位置:首页 > 编程语言 > PHP开发

yii Column name must be either a string or an array.

2013-08-06 14:57 5218 查看
转http://bbs.csdn.net/topics/390103199

之前数据库有个字段是数值型,我用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
.........
..........
........
.......
.
请问高手,这是什么原因呀?请帮忙,谢谢啊!!

解决方法:

谢谢各位呀问题解决了,Yii必须有主索引,也就是在数据库里建立一个主索引,primary key
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Yii
相关文章推荐