I'm not sure about the primary key, but instead you can set a unique index. It should give you a sort of like here .
class YourDataObject extends DataObject
{
private static $db = [
'MyField' => 'Varchar',
'MyOtherField' => 'Varchar'
];
private static $indexes = array(
'MyIndexName' => array(
'type' => 'unique',
'value' => '"MyField","MyOtherField"'
)
);
}
Using this code, it is impossible to create YourDataObject
with MyField = 'test'
and MyOtherField = 'othertest'
if there is already an entry with BOTH with these values in the database. You can YourDataObject
only create with a test MyField
and MyOtherField
like something else.
, , , ModelAdmin.