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 YourDataObjectwith MyField = 'test'and MyOtherField = 'othertest'if there is already an entry with BOTH with these values in the database. You can YourDataObjectonly create with a test MyFieldand MyOtherFieldlike something else.
, , , ModelAdmin.