[Solar-talk] Connecting to two databases

Antti Holvikari anttih at gmail.com
Tue Apr 1 12:33:31 CDT 2008


On Tue, Apr 1, 2008 at 8:13 PM, Rapoport, Aaron
<Aaron.Rapoport at gd-ais.com> wrote:
>
> Hi,
>
> im using SOLAR in a php script that connects to two databases.  SOLAR
> seems to specifically reference a class named sql in the registry from the
> Model,
> so ive declared the following for one database connection.
>
> if (Solar_Registry::exists('sql') == false)
> {
>     Solar_Registry::set('sql', 'Solar_Sql', $config);
> }
>
> how would i set up for the second connection?  If this has been covered in a
> previous thread,
> would appreciate any references.

All the Solar classes that use Solar_Sql accept a config param for a
Solar_Sql "dependency". So, if you create a second Solar_Sql instance
and put it in the registry with a different name, say `sql2`, you can
then have classes use that other connection if you give them `sql2` as
the config param for the dependency.

Hope that helps.


-- 
Antti Holvikari <http://anttih.com>


More information about the Solar-talk mailing list