Polymorf Posted December 29, 2008 Share Posted December 29, 2008 hello! I find this tutorial on the MVC he looks very interesting but I can not get too used to someone could help me? http://www.phpro.org/tutorials/Model-View-Controller-MVC.html#6 example: I would like to import a model that uses the database with PDP! and I do not know how or I can use the header (Location: ...) I started in OOP thank you for your help ! Quote Link to comment Share on other sites More sharing options...
Polymorf Posted January 8, 2009 Author Share Posted January 8, 2009 hello! I find this tutorial on the MVC he looks very interesting but I can not get too used to someone could help me? http://www.phpro.org/tutorials/Model-View-Controller-MVC.html#6 example: I would like to import a model that uses the database with PDO! and I do not know how or I can use the header (Location: ...) I started in OOP thank you for your help ! Quote Link to comment Share on other sites More sharing options...
Ninjakreborn Posted January 12, 2009 Share Posted January 12, 2009 I thin you mean "How to use MVC" MVC is just one (of many) framework patterns. So far out of all of the patterns I have used I like MVC the most. The general idea is very basic. There are 3 types of logic. The Model, the View, and the Controller. The Model is where anything related to SQl/platform specific SQL or anything related to database work. This is where your queries will go. Generally you have 1 model for each database table and those models will have configuration options to help you use that model better. Then the Controller is what does all of your "work" and gathering your data and co-ordinating with the Models and gathering everything together. Then finally the View. The Controller takes all of that data and inserts it into the "view" which simply shows that data on the screen and then formats it appropriately (Xhtml/Css would be in the view). Quote Link to comment Share on other sites More sharing options...
Polymorf Posted January 16, 2009 Author Share Posted January 16, 2009 ok thank you! I understand the principle now! the tutorial that I found is good, but Kevin Waterson who have the author does not give an example with the class db! the link is : http://www.phpro.org/tutorials/Model-View-Controller-MVC.html he put a static instance of a global script init.php but I do not know how to retrieve the body from one of my classes model! he said the matter as follows in the file init.php $registry = new registry; $registry-> db = db:: getInstance (); Now how do I recover the body in a class model that I have? because I tried that and it does not work! in one method: public function getMessage() { // an exemple for my model $request = "SELECT * FROM messages"; $pdo = $registry->query($request); return $pdo->fetch(PDO::FETCH_OBJ); } I say that I repeat my class PDO but what keeps the singleton pattern and to review always a getInstance I apologize if my English is not good! I use google translate to help me! thank you fro your help ^^ Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.