php - MVC - Keep model consistent with DB -


i'm front-end developer trying write first back-end restful webapplication in php/mysql.

what it's confusing me figure out how model works. in fe programming, wrote in angularjs, model service provides data webservice. model doesn't exists itself, services provide when calls controllers.

in backend scenario have db stocks data, , there have retrieve data compose model. problem me is: data being updated continously each client talks backend, need keep model consistent db continuously changing. had use implementation similar frontend, model have being created when controllers commands interactions it, , solves problem me.

but friend of mine (which skilled) told me approach wrong, , model have independent controllers. but, if db changes, how aware of , update model?

i hope have being clear

in backend mvc, model divided in 3 parts: domain, dao , service.

domain representation of data, in case class attributes. dao class implements access database (or files etc). there dao class each domain class , methods receive or return objects of these classes. , service controller access talk model, implements high level methods.

in way can access information of model in controllers. every time need information call service's method 'getusers()'.


Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -