I’ve to fetch data from different web services + my own database and combining these data before displaying in the site.
What’s the best method for doing this? I prefer writing separate models for web services and database. How can I organize the model classes of different data sources in different folders?
I may add more webservices later.
EDIT: I am Really sorry, as my example below will not work, as you cannot have equally named models. You should prefix them in the subdirectories as well, like:
That way you will load them as
And use as
End of edit.
To separate them in different folders simply put them in subfolders in
modelsdirectory, then use common syntax$this->load->model('web_service1/products');.I don’t know the best method, as it is a matter of preference, but if I were you, I would separate them as you said in two different models and made a third one, that would combine them to one result.
So if you have to get products from 2 different services and your database, I would make 4 models:
That way you would have to make only one request from the controller, to the
productsmodel.