i don't see no reason why you shouldn't be able to use the mvc paradigm in your php applications. it's only discplin what is needed to keep up the breakup into the three parts
MVC = model view controller design pattern
view
= all the stuff you see (in your browser)
- is responsible for all graphic or textual output
- for this visualisattion it queries the model
controller
- monitors and interprets all mouse and keyboard input
- makes the model and/or view-layer to change
- input is forwarded to the model and model-data is forwarded to the view
- controlls reaction to user input (control flow)
model
- covers all the application logic
- responds to information request (mostly from the view)
- responds to state change request (from the controller)
- responsible for working with all the data needed (business logic)
- doesn't influence the layout
example:
you have three views
- table.tpl
- graph.tpl
one controller
- output.php
and one model
- election.class.php
the controller fetches the raw election results, processes them to have the approriate format for the view you selected and passes this processes data to the view.
the view displays the election results to you as a simple table or a graph.
if you want a piechart output you simplay create a new view called piechart.tpl and in the controller code the appropriate transformation logic (if neccessary), you do not need to change the result retrieving code itself
do not call database directly from web pages
i'm quite sure this means the very same "never trust incoming data" means (and the mvc pattern itself of course)
the controller receives a submitted search request from the view (submitted by the user of course) and calls the corresponding model
to do this neither the controller nor the view need to know how to interact with the database used (mysql, oracle, postgresql, ...)
the mdel itself does all the SELECTs needed and of course validates the user's input (e. g. with the help of [man]mysql-real-escape-string[/man])
doing so you don't call the database directly from webpages imho