0

管理者ユーザーがコメント、ユーザー、クラブを表示するための3つのインスタンスがあります。現時点では、ユーザーとクラブを表示するだけで作業していますが、コメントは奇妙ではありません。すべての場合、同じコードを使用しましたが、それぞれ変数を置き換えました。

コメントモデル:

<?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>

これらを何度も再入力しようとしましたが、どこかで問題が発生し、それがどうなるか迷っています。

ありがとう

4

1 に答える 1

0

申し訳ありませんが、データベースのフィールド名が間違っていました。'date'だけでなく、'comment_date'である必要があります

ごめん

于 2012-04-15T21:37:23.970 に答える