In the framework I am using, I shall group things into models, controller, and views (I added services).
When getting things out from database, it is pure data in array form. So they won't have methods with them.
As the title asked, is it common sense to convert database data to object first? That is to say, I may then have five layers in my project, model, service, object, controller, view.
And I am very puzzled on how to sort these layers or how to specify their jobs. And it also concerns me that if there be any multi-thread problems, IO problems and such.
I have loads of questions and this is only one of them.
I used to use JavaSE to make some game bot programs and games. OOP seems quite nice and I love it very much. I store everything as object in the RAM or sometimes serialized in txt file.
But now I am doing a PHP job building website. When I met MVC and database, things changed that I created much fewer object and tackle with more arrays. Sometimes I need to do something with the data like isValid()
, I have to create a function somewhere - where I am not sure to put - and takes in a param like isValid($obj)
.
rows[row_num][5]
in order to print out that product title.