We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Delete models with composite primary key

Hello I have table with two integer fields game_id platform_id, this table is needed to implement many to many relation. I want to delete a row from this table, but did not find a way how.

$platforms = GamePlatform::find([
    'conditions' => 'game_id = :gid:',
    'bind' => ['gid' => $game->id],
]);

$platforms->delete();

I have this error: A primary key must be defined in the model in order to perform the operation



98.9k

Does your table have a primary key defined?