Closed polmartinez closed 8 months ago
Afaik that is not supported.
I think it can be done by adding it as the 3rd argument of \DBUtil::create_table
e.g.
\DBUtil::create_table('posts', [
'id' => array('type' => 'int', 'constraint' => 5),
'title' => array('type' => 'varchar', 'constraint' => 100),
'body' => array('type' => 'text'),
], ['id', 'title']);
Would make id and title the primary key.
The base model class itself has protected static $_primary_key = array('id');
so I imagine that just replacing the array with the multiple keys should be ok.
The docs (https://fuelphp.com/docs/packages/orm/crud.html) say you will have to pass an array to the find
method e.g.
// ...or when using compound primary keys
$entry = Model_Article::find(array(2, 'foo'));
Aren't you mixing ORM models and Model_Crud ?
The ORM fully supports compound keys, but in Model_Crud, only a string is supported.
https://github.com/fuel/core/blob/1.9/develop/classes/model/crud.php#L22
Yep, sorry. I assumed it was extending the Orm\Model
class.
Ha, no, Model_Crud is an entry level basic model, only working only on a single table, using DB calls.
how can we indicate that we use a PK of more than 1 field in crud models?