Accessing a remote database, multiple controllers

Hi all,

I’m building a web site which needs to access a remote database by establishing a TCP/IP session and sending XML requests / responses. I have a library already written in PHP to do this.

I would like to use yii2 to build the user facing elements of this site, local database work and invoke queries to the remote databases, but I am struggling with the best way to fit this in to a MVC pattern.

What I was planning to do is to was create a model and controller for the network library with methods for network calls in the model and a set of controller action methods to invoke them. There will be sessions open to three or four separate remote databases at once so the controller methods will do the work of deciding which session to use for a particular query.

I was also planning on a separate model, view and controller for the user interface which will contain a set of forms. When a user submits a form, the form contents will be used to query/update one of the remote databases using the network library.

I have two questions I’m hoping someone can help me with:

i) Am I using MVC properly? Is there a better way?

ii) If yes, the UI controller and network library controller will have to communicate i.e UI controller sends a request to the network library controller and then waits for/processes a response (success/fail etc). I can’t find any examples of how to do this. Do I need to do this via URL routing or is there a better way?

It could be that I’m way off base here, so any guidance on how I should tackle this would be appreciated.

Best wishes,