model view controller - MVC Frameworks (PHP in this case) -


possible duplicate:
how implement mvc scratch in php?

let me straight:

model = database table name


controller = middle man between user interaction , application logic


view = ??

so view dynamic php page or fragment of html?

i'm hoping can head around mvc's because want implement them soon

the following explanation of mvc taken codeigniter user guide.

  • the model represents data structures. typically model classes contain functions retrieve, insert, , update information in database.

  • the view information being presented user. view web page. view can page fragment header or footer. can rss page, or other type of "page".

  • the controller serves intermediary between model, view, , other resources needed process http request , generate web page.

http://codeigniter.com/user_guide/overview/mvc.html

edit: example of may include in each entity

controller (this file targeted browser)

<?php     //assuming database has been connected      //include model     require('members_model.php');     //get posts made particular user database)     $posts = $this->members_model->get_posts($_post['member_id']);     //output view     require('members_posts.php'); ?> 

model

<?php     class members_model {          //function posts made particular member         public function get_posts($member_id) {             $query = mysql_query("                 select *                 posts                 author = ".$member_id             );             return mysql_fetch_array($query);         }      } ?> 

view

<html>     <head>         <title>all posts member</title>     </head>     <body>         <?php foreach($posts $post): ?>             <h1><?=$post['title']?></h1>             <span><?=$post['date']?></span>             <?=$post['body']?>         <?php endforeach; ?>     </body> </html> 

obviously, extremely simplified example gives rough idea of should going where.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -