开发者

Zend RestController > Get data using model or controller?

开发者 https://www.devze.com 2023-02-08 18:43 出处:网络
Iam building a Zend Rest Controller, and iam unsure about where to get the data from. Basically i need to output the database data as xml format to the view.

Iam building a Zend Rest Controller, and iam unsure about where to get the data from. Basically i need to output the database data as xml format to the view.

Do i employ a model to 开发者_JS百科controller data exchange,

or just query database and get the data in the controller itself, without the need of a model?

I see, most of the people are employing the latter scenario


In additional to using a full MVC approach, I have read about people using Zend_Rest_Server, the argument being that you don't need to incur the overhead of the full MVC stack in order to handle such a request.

However, if you do choose to go with handling the request via MVC, then you can use a context-switch to change the view rendered.

However, in both cases, I believe it is generally preferable to have a service/model to access the data. This makes the access code more re-usable in other situations.

0

精彩评论

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

关注公众号