It is mentioned in yii guide, a bit not highlighted through.
In short, just ovveride method primaryKey
like that:
public function primaryKey()
{
return array('pk1', 'pk2');
}
Also see Yii Model with composite primary key
Domanda
I am stuck in creating composite primary key in yii...i have following tables..
**Branche**
id
name
**Item**
id
name
**branch_item**
branch_id
item_id
how to create branch_item in yii with composite primary key...(and crud with gii)
is it ok if i create table like this...
**branch_item**
id (this is the primary key)
branch_id (unique key)
item_id (unique key)
what is the best way create composite id or create id with unique keys...
Soluzione
It is mentioned in yii guide, a bit not highlighted through.
In short, just ovveride method primaryKey
like that:
public function primaryKey()
{
return array('pk1', 'pk2');
}
Also see Yii Model with composite primary key