开发者

Online music application design question on php and mysql

I was thinking of using mvc pattern while designing this app. How can I use mvc here ? The model will be stored in mysql but what will be the controller and what will be开发者_JAVA技巧 the view here ?


Firstly: model won't be stored in MySQL database - the data will, and model != database [sometimes it is very related, but it is not equal overall]. Your controllers will probably handle such things like:

  • login
  • logout
  • register
  • select album
  • select song

The view would be HTML page, but probably also some external app or embedded JS that people can place in their pages.


Go do the Zend Framework tutorial. It's free (as is the framework) and it will probably save you hours and hours of time.


MVC is not just something you can use in PHP by default, you need a framework. MVC is an acronym for Model View Controller, which is a style of web application development that takes advantage of layering tasks and separating out your data, views, and backend processing. These frameworks for web development are use when creating websites.

There are a bunch out there, with a few popular ones being the Zend Framework, CakePHP, and Symfony.


In MVC, the model is a class that represents data, in you case it will be a class that represent a tables in your mysql database e.g. Song class for song table.

Views are front end representation of data e.g. A list of top ten song for given week.

Controllers are programs that processes user request and gather data from different models, then redirect you request to specific view.

You can make your mvc framework from scretch if you want but I recommend you use an open source framework.

I use CodeIgniter framework for MVC projects in PHP. It is small and easy to use.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜