Closed luchothoma closed 6 years ago
I solve it, it need the $ObjectToDelete, not the $id, althoug it will be useful update/add it to documentation.
Unfortunately there are a lot of undocumented features in spot. I wanted to upgrade the documentation so many times in the past months.......
You can do it both ways:
$mapper->delete($entity);
or
$mapper->delete([$primaryKeyField => $entity->$primaryKeyField]);
Shouldn't your second line be :
$mapper->delete([$mapper->primaryKeyField() => $entity->primaryKey()]);
?
That being said, if you pass an object (so an entity most of the time) to $mapper->delete
, that's almost what's being done internally by spot (as seen here), so you shouldn't have to do it manually most of the time.
I was writing an example from the top of my head, and I implicitly set the $primaryKeyField
variable. Ofc you can delete an entity if you pass it to $mapper->delete
, but you can delete entities if you provide a fitting $options
array as well.
Feel free to reopen this thread if you need further assistance.
I am new with Spot and in the doc http://phpdatamapper.com/docs/crud/ It does not say how to Delete an entity.... I try with ->delete( $primariKeyValue ) but it not works.