Php 从视图脚本中选择正确的记录
我只是想熟悉Zend Framework 2。我尝试了每个组件的不同可能性。现在我正在测试viewscripts,以便更好地了解细节。问题是,我不知道如何选择要删除的正确记录。我总是第一个 我有一个html格式的viewscript,如下所示:Php 从视图脚本中选择正确的记录,php,zend-framework2,zend-db,Php,Zend Framework2,Zend Db,我只是想熟悉Zend Framework 2。我尝试了每个组件的不同可能性。现在我正在测试viewscripts,以便更好地了解细节。问题是,我不知道如何选择要删除的正确记录。我总是第一个 我有一个html格式的viewscript,如下所示: <table> <tr> <th>Tag</th> <th>Datum</th> <th>Zeit</th&
<table>
<tr>
<th>Tag</th>
<th>Datum</th>
<th>Zeit</th>
<th>Thema</th>
<th></th>
</tr>
<?php
$lodge = new Application_Model_DbTable_Arbeitskalender();
$i=1;
foreach($this->aktermine as $termin) :
?>
<tr>
<td class="row_<?PHP echo $i % 2;?>"><?php echo $this->escape($termin->nr);?></td>
<td class="row_<?PHP echo $i % 2;?>"><?php echo $this->day($termin->datum);?></td>
<td class="row_<?PHP echo $i % 2;?>"><?php echo $this->date($termin->datum);?></td>
<td class="row_<?PHP echo $i % 2;?>"><?php echo $this->escape($termin->zeit);?></td>
<td class="row_<?PHP echo $i % 2;?>"><?php echo $this->escape($termin->thema);?></td>
<td class="row_<?PHP echo $i % 2;?>">
<a href="<?php echo $this->url(array('controller'=>'aktermine', 'action'=>'edit', 'kopfnr'=>$termin->kopfnr));?>">
<img src="Images/Icons/edit.jpg" width="16" height="16" title="Termin editieren" /></a>
</td>
<td class="row_<?PHP echo $i % 2;?>">
<a href="<?php echo $this->url(array('controller'=>'aktermine', 'action'=>'delete', 'kopfnr'=>$termin->kopfnr));?>">
<img src="Images/Icons/minus.jpg" width="16" height="16" title="Termin entfernen"/></a>
</td>
<td class="row_<?PHP echo $i % 2;?>">
<a href="<?php echo $this->url(array('controller'=>'aktermine', 'action'=>'add', 'kopfnr'=>$termin->kopfnr));?>">
<img src="Images/Icons/plus.jpg" width="16" height="16" title="neuer Termin"/></a>
</td>
</tr>
<?php
$i=$i+1;
endforeach;
?>
问题解决了。我的get函数中有一个复制/粘贴错误,我使用了外键而不是主键。如果您刚开始使用ZF2,那么您的第一个项目应该是。谢谢,我已经这么做了,但是现在我正在尝试不同的可能性来获得相同的结果
public function deleteAction()
{
if ($this->getRequest()->isPost()) {
$del = $this->getRequest()->getPost('del');
if ($del == 'Yes') {
$nr = $this->getRequest()->getPost('nr');
$aktermine = new Application_Model_DbTable_Aktermine();
$aktermine->deleteTermine($nr);
}
$urlOptions = array('controller'=>'aktermine', 'action'=>'index');
//redirector = Seitenaufruf controller, action
$this->_helper->redirector->gotoRoute($urlOptions);
} else {
$nr = $this->_getParam('kopfnr', 0);
$aktermine = new Application_Model_DbTable_Aktermine();
$this->view->aktermine = $aktermine->getTermine($nr);
}
}