Flourish PHP Unframework
This is an archived copy of the forum for reference purposes

one-to-one

posted by mungiu 8 years ago

i have a one to one relationship, i dont know if i do wrong something or its a bug or this is how must to work, so if a try to delete record from A says that it cant because have a record on B, and in B the same think when i try to delete says have a related record in A.

What did you set the ON DELETE clause in your foreign key constraint to? For most RDBMS if you don't specify one, it sets it to ON DELETE NO ACTION which means you can't delete one row if another references it.

If it makes sense, you should update that ON DELETE to ON DELETE CASCADE. If it doesn't and you only want to allow deleting sometimes, you can pass TRUE to ->delete() and it will force both to be deleted.

// Delete the record even if there are records that
// reference it with an ON DELETE NO ACTION constraint
$record->delete(TRUE);
posted by wbond 8 years ago

so its normal to happend this thing? what i want it's that only row form A table who have foreign key to B to get error on delete. i think i put on delete restrict, but i'm asking on this behavior if its corect to not let it to delete any of thow rows, sound like a strange behave.

posted by anonymous 8 years ago

so practically in this case if its one to one none of thow related record can be deleted.

posted by mungiu 8 years ago