用户名: 密码: 忘记密码? 注册
收藏此问题 发表新评论

请各位学长指点一下MVC思路

我的留言有回复的
many thanks
controller
class listController extends Controller {    
    function __construct(& $dao) {
        parent::__construct($dao); 
        $notes = $this->model->listNote();
        $this->view = new listView($notes);
        $replys = $this->model->listReplyNote();
        $this->view = new listView($replys);
    }
}

model
    function listNote() {  
        $notes = $this->dao->fetchRows("select *from note order by id desc");
        return $notes;
    }

    function listReplyNote() { 
        $replys = $this->dao->fetchRows("SELECT * FROM reply WHERE noteid='" . $note['id'] . "' ORDER BY timedate DESC");
        return $replys;
    }

view
class listView extends View    {

    function __construct($notes) {
        $this->output.="<div class='msglist'>" .
                "<form name='form1' method='post' action='do.php'>" .
                "<div class='posttip'>列表" .
                "<span class='print'>全選" .
                "<input type='checkbox' >" .
                "<input type='submit' name='upd'>" .
                "</span>" .
                "</div>" .
                "<div class='showmsg'>";
        foreach ($notes as $note) {
            $this->output.="<ul onmouseover=\"show('msg" . $note['id'] . "')\" onmouseout=\"show('msg" . $note['id'] . "')\">" .
                    "<li class='msgtop' id='msg" . $note['id'] . "' style='display:none;'> " .
                    "<span class='building'>" .
                    "<a id='replytxt'>回復</a>  " .
                    "<a>刪除</a>" .
                    "<input type='checkbox' name='id[]' value=''>" .
                    "</span>" .
                    "<span class='nickname'><b>用戶:</b>" . $note['author'] . "</span> <b>時間:</b>" . $note['adddate'] . "" .
                    "</li>" .
                    "<li class='msgcont' id='msgcont'>" .
                    "" . htmtocode($note['content']) . "" .
                    "<div class='replyaction' id=''>" .
                    "<textarea id='replymsg'  class='replymsg'></textarea><br/>" .
                    "<input name='Submit' type='button' class='bt' id='bt_sendr' value='提交回復' />" .
                    "<span id='replysending' style='display:block; width:50px;'></span>" .
                    "</div>";
					foreach ($replys as $reply) {
                    $this->output.="<div class='reply'><b>[]</b> 回復:<br/>" .
                    "</div>" ;
					}
                    $this->output.="</li>" .
                    "</ul>";
        }
        $this->output.="</div></form>" .
                "<div class='pagenav'>" .
                "</div>" .
                " </div>" .
                "</div>" .
                "</div>";
    }

}


昵称: carlkyo  时间: 2013-06-19 11:04:38
你用的是?
昵称: mckee1990  时间: 2013-06-19 11:36:46
找几个流行的开源PHP框架看一下源码学习
昵称: 网鬼  时间: 2013-06-19 11:42:17
我不知道我的理解对不对,你是不是想知道怎么处理回复问题?

个人觉得你在用户点击回复的时候可以走controller,在控制器中建个方法,然后跳转view层,通过view层调动model层中的数据进行处理,然后返回数据给前台,我不知道我这样说能不能对你有帮助。
昵称: tommercatfly  时间: 2013-06-19 12:14:38
你到底想问什么呢,一句MVC太宽泛了,没人能回答你。
提问的智慧
昵称: iminto  时间: 2013-06-19 12:14:47
发表评论
昵称:
内容:
验证: