2009年9月10日星期四

Re: [fw-db] Something fishy with adapters in Zend_Db

I reviewed more stuff and had some more thoughts on this, and I think that
one is a tough one.

Since we have a PDO module called PDO_IBM, that's why a
Zend_Db_Adapter_Pdo_Ibm adapter has been created. There's not much choice,
because the other PDO adapters are based on their respective PDO module
(beside MSSQL, should be named Dblib.php instead of Mssql.php) but it breaks
something else. You can't use Zend_Db_Adapter_Pdo_Ibm_Db2 directly, so far
you could instantiate all PDO adapters directly.

Ideally, Zend_Db_Adapter_Pdo_Ibm_Db2 would derive from
Zend_Db_Adapter_Pdo_Ibm, but in our scenario, it can't be done. The factory
will give you a Zend_Db_Adapter_Pdo_Ibm.

I think the programmer did the best that could be done in this situation. My
question is, how could adapters, at least at the PDO level, be redesigned to
allow polymorphism with Pdo_Ibm_Db2 and Pdo_Ibm_Ids or any similar situation
that could manifest itself in the future?

I think the idea of having a PDO module which could interface to more than
one type of database should be implemented at the factory level maybe, or
somewhere else. Right now, the factory will know you are connecting to
PDO_IBM, but won't know what database is it. It could be DB2 or Informix.
Only once you are connected can you find out what database it is, by
fetching server info from the server (that's the way it's done in
Zend_Db_Adapter_Pdo_Ibm anyway).


--
View this message in context: http://www.nabble.com/Something-fishy-with-adapters-in-Zend_Db-tp25388420p25390160.html
Sent from the Zend DB mailing list archive at Nabble.com.

没有评论: