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的工具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
相关文章推荐
- Column name must be either a string or an array yii
- A context path must either be an empty string or start with a '/' and do not end with a '/' 问题解决方法
- c++ 编译时报错 "Array initializer must be an initializer list or string literal"
- tomcat 7 WARNING: A context path must either be an empty string or start with a '/' and do not end with a '/'. The path [/] does not meet these criteria and has been changed to []
- Err:The "." operator was supplied with an index value of type "java.lang.String" to be applied to a List or array
- Name of an object member must be a string
- Generic detail view DetailView must be called with either an object pk or a slug.
- TypeError: name must be an instance of basestring
- zizaco/entrust 5.2.x-dev Class name must be a valid object or a string
- Synthesized property 'xx' must either be named the same as a compatible ivar or must explicitly name
- 【解决】Element type "typename" must be followed by either attribute specifications, ">" or "/>".
- Unable to determine the principal end of an association between the types '***. The principal end of this association must be explicitly configured using either the relationship fluent API or data annotations.
- ERROR Error: If ngModel is used within a form tag, either the name attribute must be set or the form
- [HOOLOO] zizaco/entrust 5.2.x-dev Class name must be a valid object or a string
- Python TypeError: must be string or buffer, not dict
- Android Studio 3 Error Message:The activity must be exported or contain an intent-filter
- Android Build with Gradle and ProGuard : “The output jar must be specified after an input jar, or it
- Uncaught (in promise) TypeError: Super expression must either be null or a function
- The type of the expression must be an array type but it resolved to Point
- Uncaught TypeError: Super expression must either be null or a function, not undefine