Write your own MVC with PHP
Posted: Thu Jun 03, 2010 1:31 pm
this is the best MVC tutorial I came across so far,
http://php-html.net/tutorials/model-vie ... er-in-php/
I am new to MVC and I am still confused with the class Model and the class book in the example of that tutorial...
for instance, I have my website and the content of my webiste is pulled from a database... so when I request a specific page for instance, http://www.mysite.com/index.php?pg=profile or with clean url http://www.mysite.com/profile
so usually, I will get the content from the SQL query,
$sql = "
SELECT * FROM root_pages
WHERE root_pages.pg_url = '".$_REQUEST['pg']."'
";
so then should this $sql be put in the book class or model class??
or this should be in the controller class actually?
I have a directory folder which keeps all my CMS files, which contains update, insert, delete SQL queries, html forms, and pages that display the db items into lists, etc.
so if I implement MVC on my website, then I am going to relocate these CMS files into different locations, like some in the model folder, and some in view folder and others in controller folder, is it correct??
many thanks,
Lau
http://php-html.net/tutorials/model-vie ... er-in-php/
I am new to MVC and I am still confused with the class Model and the class book in the example of that tutorial...
for instance, I have my website and the content of my webiste is pulled from a database... so when I request a specific page for instance, http://www.mysite.com/index.php?pg=profile or with clean url http://www.mysite.com/profile
so usually, I will get the content from the SQL query,
$sql = "
SELECT * FROM root_pages
WHERE root_pages.pg_url = '".$_REQUEST['pg']."'
";
so then should this $sql be put in the book class or model class??
or this should be in the controller class actually?
I have a directory folder which keeps all my CMS files, which contains update, insert, delete SQL queries, html forms, and pages that display the db items into lists, etc.
so if I implement MVC on my website, then I am going to relocate these CMS files into different locations, like some in the model folder, and some in view folder and others in controller folder, is it correct??
many thanks,
Lau