2012-04-12 35 views
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> 

我曾尝试重新输入这些多次,但一些地方是怎么回事错了,我失去了它会是什么。

谢谢

+1

在你的'的indexAction()'方法做一个'的var_dump($这个 - >查看 - >评论)'您本地化后,看如果你有价值观,这可能是一个逃避的问题。 – 2012-04-12 16:33:08

+0

像这样 - > http://pastebin.com/5XFqS0ji它不会改变任何东西.. – Rik89 2012-04-12 17:13:17

+0

它不应该改变任何东西,它只是为了确认你确实有评论数据。 – 2012-04-12 17:51:46

回答

0

对不起,你们在数据库中的字段名称是错误的!这本来应该是 'COMMENT_DATE',不只是 '日期'

对不起