表里面有组合主键时生成curd 时提示该表不被支持 [ 新手入门 ]
表里面有组合主键时生成curd 时提示该表不被支持 要怎么解决呢
大家有没有碰到这样的情况呢
有什么方法解决呢
共 5 条回复
-
getPrimaryKey() method public mixed getPrimaryKey() {return} mixed the primary key value. An array (column name=>column value) is returned if the primary key is composite. If primary key is not defined, null will be returned. Source Code: framework/db/ar/CActiveRecord.php#1213 (show) public function getPrimaryKey() { $table=$this->getMetaData()->tableSchema; if(is_string($table->primaryKey)) return $this->{$table->primaryKey}; else if(is_array($table->primaryKey)) { $values=array(); foreach($table->primaryKey as $name) $values[$name]=$this->$name; return $values; } else return null; } Returns the primary key value.
-
http://www.yiiframework.com/doc/guide/1.1/en/database.ar#defining-ar-class
AR relies on well defined primary keys of tables. If a table does not have a primary key, it is required that the corresponding AR class specify which column(s) should be the primary key by overriding the primaryKey() method as follows, public function primaryKey() { return 'id'; // For composite primary key, return an array like the following // return array('pk1', 'pk2'); }
348714556
注册时间:2011-09-23
最后登录:2017-05-23
在线时长:7小时7分
最后登录:2017-05-23
在线时长:7小时7分
- 粉丝2
- 金钱268
- 威望5
- 积分388