php - Loose coupling with data source -
first of sorry not able provide details , question might sound general.
i working on small project requirement of project bit wired. have make data source switchable. if using database data source in future might able use web service or files.
i don't have clue on how implement models can switch data source without making major changes application.
is there design pattern or design practices can use deal situation?
i planning on using zend framework.
thanks in advance.
take @ daos (data access object). it's existing in j2ee world simple, thin , usefull.
first define interface whatever function need:
<?php interface daointerface { public function insert($object); public function remove($object); public function create($object); }
then create concrete implementation of it. implementation exchangeable dependecy injection (di). can have several different ways of storing data now. you'll use interface + di.
one interface ->multiple differen implementations / ways of stroing data. typically 1 dao = 1 database object / table.
Comments
Post a Comment