View one record
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;
}
config/module.config.php
'data' => [
'type' => Segment::class,
'options' => [
'route' => '/data[/:action[/:id]]',
'defaults' => [
'controller' =>
ControllerIndexController::class,
'action' => 'index',
],
],
],
FlowerTable
public function getFlower(int $id)
{
$current=$this->tableGateway->select(['id'=>$id]);
return $current->current();
}
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>

10. view one record