Embed presentation

![IndexController
public function deleteAction()
{
$id=(int)$this->params()->fromRoute('id',0);
if($id==0){
exit('invalid id');
}
$flower=$this->table->getFlower($id);
$request=$this->getRequest();
if(!$request->isPost())
{
return new ViewModel(['flower'=>$flower,'id'=>$id]);
}
$del=$request->getPost('del','No');
if($del=='Yes'){
$id=(int)$flower->getId();
$this->table->deleteFlower($id);
}
$this->redirect()->toRoute('data',['action'=>'index']);
}](https://image.slidesharecdn.com/11-190526113618/85/11-delete-record-2-320.jpg)
![FlowerTable
public function deleteFlower(int $id)
{
$current=$this->tableGateway->delete(['id'=>$id]);
}](https://image.slidesharecdn.com/11-190526113618/85/11-delete-record-3-320.jpg)
![view/data/index/delete.phtml
<?php
$url=$this->url('data',['action'=>'delete','id'=>$id]);
?>
<h1>Are you sure?</h1>
<form action="<?php echo $url; ?>" method="post">
<input type="hidden" name="id" value="<?php echo $id; ?>">
<input type="submit" name="del" value="Yes">
<input type="submit" name="del" value="No">
</form>](https://image.slidesharecdn.com/11-190526113618/85/11-delete-record-4-320.jpg)

This document contains code for deleting a record from a database table. The deleteAction method in the IndexController checks if the ID is valid, gets the flower record, and checks if a POST request is made. If the form submits "Yes", it calls the deleteFlower method to remove the record from the table. It then redirects to the index action. The deleteFlower method in FlowerTable deletes the record from the database. The view displays a confirmation form to submit "Yes" or "No" for deleting.

![IndexController
public function deleteAction()
{
$id=(int)$this->params()->fromRoute('id',0);
if($id==0){
exit('invalid id');
}
$flower=$this->table->getFlower($id);
$request=$this->getRequest();
if(!$request->isPost())
{
return new ViewModel(['flower'=>$flower,'id'=>$id]);
}
$del=$request->getPost('del','No');
if($del=='Yes'){
$id=(int)$flower->getId();
$this->table->deleteFlower($id);
}
$this->redirect()->toRoute('data',['action'=>'index']);
}](https://image.slidesharecdn.com/11-190526113618/85/11-delete-record-2-320.jpg)
![FlowerTable
public function deleteFlower(int $id)
{
$current=$this->tableGateway->delete(['id'=>$id]);
}](https://image.slidesharecdn.com/11-190526113618/85/11-delete-record-3-320.jpg)
![view/data/index/delete.phtml
<?php
$url=$this->url('data',['action'=>'delete','id'=>$id]);
?>
<h1>Are you sure?</h1>
<form action="<?php echo $url; ?>" method="post">
<input type="hidden" name="id" value="<?php echo $id; ?>">
<input type="submit" name="del" value="Yes">
<input type="submit" name="del" value="No">
</form>](https://image.slidesharecdn.com/11-190526113618/85/11-delete-record-4-320.jpg)