348714556 2011-09-24 18:10:42 2705次浏览 5条回复 0 0 0

表里面有组合主键时生成curd 时提示该表不被支持 要怎么解决呢

大家有没有碰到这样的情况呢

有什么方法解决呢

  • 回复于 2011-09-25 10:52 举报

    没有人知道怎么解决吗

  • 回复于 2011-09-25 14:53 举报

    不要用就好了么。

  • 回复于 2011-09-25 21:57 举报
    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.
    
  • 回复于 2011-09-26 20:20 举报

    版主 能说下要具体怎么用吗?
    刚看了两天框架
    能不能说下 要具体怎么调用呢

    是不是直接在model 里面调用这一个方法

  • 回复于 2011-09-28 20:49 举报

    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');
    }
    
您需要登录后才可以回复。登录 | 立即注册