1
votes

I have a number of tables in my MySQL database and use them to collect information using views. According to Phalcon's tutorial, models should be created for each table, and their source should be set, but does this also apply on views?

1
I think that a view is treated just like a table. Have you tried creating a model for the view just like you would an ordinary table? - the-notable
Creating models for each view would be one of the solutions. The problem in my case is that I am creating a RESTful api and have at least 20 views, so creating models might not be efficient. My practice is to keep the sql statement in php as simple as possible. Thanks - chunchiu Chan
Yes, creating models for that many views may be tedious, but you shouldn't need to write any SQL. After the models are created you can access everything in an OO way. - the-notable

1 Answers

0
votes

To answer your question, yes, views are treated the same as tables, and a model is needed for each view.