is this an MVC?
this is a General Question about MVC ..
I wrote a PHP Class that send an Array with Core JsonData Strings to Jquery .. and on Jquery i´m accessing the data and add them to my views ( .append("htm stuff"+jsondata) )
now the Jquery is calling the data from a between.php page that has a catch block with many cases, and upon the called case/function , the between page is calling a function from the php class that sends the json data ..
so i have my oop php mo开发者_如何学JAVAdel that send the core jsondata , a controller ( catch block), and the view ( the jquery page) .. is this kind of MVC ? or i did miss understand it ?
an example of my code was posted on a previous Question here
Looking at the code you posted in your other post it is not a MVC implementation. Or at least it is a bad implementation.
The MVC is about seperating your presentation from your business logic. Looking at your POST class you don't seperate your business logic from your view:
public static function readPosts(){
$query = new Post_db("SELECT * FROM pmessage
ORDER BY p_id DESC
");
$posts = array();
while($row = $query->fetchRow()){
$posts [] = new Post($row);
}
foreach($posts as $item){
echo $item;
}
}
In this function you get information from your database (business logic) and print content (view). In other words, you combine your MV in one method. So I would say: No, this is not MVC.
In simple word MVC is a pattern, but it should follow some pattern in coding i.e. separation of concern
- Model: the property class ,basically container for table data
- View:Simple HTML Pages that show data using the models.
- Controller:It send commands to the model to update the model's state .It also work like a router that send model to view and vice-versa.
see the below link for reference...
Help Link
Anything that satisfies or follows Model-View-Controller pattern is called MVC. It's up to us to take it in this way or the other.
In my opinion, like I said if it satisfies MVC needs then call it MVC.
精彩评论