Horde_Rdo - getAdapter() method more flexible

View: New views
1 Messages — Rating Filter:   Alert me  

Horde_Rdo - getAdapter() method more flexible

by Elier Delgado :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Chuck, thanks for your previous answer.

I'm designing a Driver to manage some related mappers and Rdo_Base
subclasses (related tables),
so could share the same adapter, but override the getAdapter() method
seem not flexible
If I needed 2 instances of my Driver with 2 different adapters.

By all allowed way, the Adapter for the Mapper will be fixed.

To allow this I must give Adapter or connection data by params, but
the Mapper constructor
do not allow params, specially in the Mapper created for relationships.

Well, I put a $_params attribute in my base Mapper and allow the
access from the Rdo_Base subclasses,
I pass the connection data to Mappers constructors and the
getAdapter() create the adapter from $_params:

$this->_params['adapter'] = 'pdo_' . $this->_params['phptype'];
return Horde_Db_Adapter::factory($this->_params);

And when the Mapper is created for relationships I provide the params:

if (isset($rel['mapper'])) {
    $m = new $rel['mapper']($this->params);
    //$m = new $rel['mapper']();

Well, that worked, but which are your opinion ?
There is another way to do that without modify Horde_Rdo_Base ?

Thanks in advanced, Elier
--
Horde mailing list - Join the hunt: http://horde.org/bounties/#horde
Frequently Asked Questions: http://horde.org/faq/
To unsubscribe, mail: horde-unsubscribe@...