I would like to know how I delete rows based on both the id of the record and also another field, let’s say, email address; in this case, the user’s email.
$contactsTable= TableRegistry::getTableLocator()->get('Contacts');
$contactEntity=$contactsTable->get($Id);
$contactsTable->delete($contactEntity);
This successfully deletes the row by its id, but the problem is that I also need to delete the row based on the user’s email.
My contacts
table:
id
name
email
phone
address
user_email
In this case, the user_email
is the email of the user who saved the contact and I would like to only delete that contact when both id and the user email match.
How do I do it using entities? I took a look at the documentation but I couldn’t find anythiing regarding that.
Thank you in advance.