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.

10. view one record

81 views

Published on

http://www.rraducanu.ro

Published in: Education
  • Be the first to comment

  • Be the first to like this

10. view one record

  1. 1. View one record
  2. 2. IndexController public function viewAction() { $id=(int)$this->params()->fromRoute('id',0); if($id==0){ exit('invalid id'); } try{ $flower=$this->table->getFlower($id); } catch (Exception $e) { exit('Error!'); } $request=$this->getRequest(); $viewModel = new ViewModel(array('flower'=>$flower)); $viewModel->setTemplate('data/index/view'); return $viewModel; }
  3. 3. config/module.config.php 'data' => [ 'type' => Segment::class, 'options' => [ 'route' => '/data[/:action[/:id]]', 'defaults' => [ 'controller' => ControllerIndexController::class, 'action' => 'index', ], ], ],
  4. 4. FlowerTable public function getFlower(int $id) { $current=$this->tableGateway->select(['id'=>$id]); return $current->current(); }
  5. 5. view/data/index/view.phtml <ul> <li>Nume: <?php echo $flower->getNume();?></li> <li>Culoare: <?php echo $flower->getCuloare();?></li> <li>Marime: <?php echo $flower->getMarime();?></li> <li>Pret: <?php echo $flower->getPret();?></li> </ul>

×