andremolnar
|
 |
« on: October 13, 2009, 08:56:34 » |
|
Hello all.
This must be a common question and I did see some discussion about it as it relates to an AIR app, but I got a bit lost:
Basically what I would like to do is share a database connection between proxies.
First thought: Just make the connection in each proxy. Conclusion: That's just silly.
Second thought: Create a multiton that returns a database connection (actually a PDO object). Then add DbConnection::getInstance('instancename') to the proxy constructor. That way the connections are shared and I have the flexibility to have more than one database connection type and I can share as many of them as I like/need between any number of proxies. Conclusion: I've built in a dependency.
Third thought: Use the same multiton (for the same reasons), but inject the dependency. Conclusion: Ummm, I'm not sure, because I would have to inject the database connection object from the point where I create the proxy (i.e. a command). Is that the place for me to be getting that connection instance? I really don't see where else I could do it.
Or am I barking up the wrong tree altogether?
Thoughts?
andre
|