Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

11. delete record

118 views

Published on

http://www.rraducanu.ro

Published in: Education
  • Be the first to comment

  • Be the first to like this

11. delete record

  1. 1. Delete record
  2. 2. 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']); }
  3. 3. FlowerTable public function deleteFlower(int $id) { $current=$this->tableGateway->delete(['id'=>$id]); }
  4. 4. 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>

×