[horde] Horde_Rdo - getAdapter() method more flexible

Elier Delgado elier.delgado at gmail.com
Fri Oct 2 05:03:53 UTC 2009

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

More information about the horde mailing list