0
嘿,我有3個管理員用戶顯示評論,用戶和俱樂部的實例。目前我正在努力讓他們顯示用戶和俱樂部工作正常,但評論並不奇怪,因爲他們都使用相同的代碼,但分別替換變量。ZendFramework從數據庫中提取數據出錯
評論型號:
<?php
class Application_Model_DbTable_Comments extends Zend_Db_Table_Abstract
{
protected $_name = 'comments';
public function getComments($id) {
$id = (int) $id;
$row = $this->fetchRow('id = ' . $id);
if (!$row) {
throw new Exception("Count not find row $id");
}
return $row->toArray();
}
}
AdminViewCommentsController:
<?php
class AdminViewCommentsController extends Zend_Controller_Action
{
public function init()
{
/* Initialize action controller here */
}
public function indexAction()
{
$this->view->assign('title', 'Admin - View Comments');
$this->view->headTitle($this->view->title, 'PREPEND');
$comments = new Application_Model_DbTable_Comments();
$this->view->comments = $comments->fetchAll();
}
}
最後認爲:
<table>
<th>Comment</th>
<th>Date</th>
<th></th>
<?php foreach($this->comments as $comments) : ?>
<tr>
<td><?php echo $this->escape($comments->comment);?></td>
<td><?php echo $this->escape($comments->date);?></td>
<td><a href="#">Delete!</a></td>
</tr>
<?php endforeach; ?>
</table>
我曾嘗試重新輸入這些多次,但一些地方是怎麼回事錯了,我失去了它會是什麼。
謝謝
在你的'的indexAction()'方法做一個'的var_dump($這個 - >查看 - >評論)'您本地化後,看如果你有價值觀,這可能是一個逃避的問題。 – 2012-04-12 16:33:08
像這樣 - > http://pastebin.com/5XFqS0ji它不會改變任何東西.. – Rik89 2012-04-12 17:13:17
它不應該改變任何東西,它只是爲了確認你確實有評論數據。 – 2012-04-12 17:51:46