[Solar-talk] Connecting to two databases

Antti Holvikari anttih at gmail.com
Tue Apr 1 13:17:11 CDT 2008


On Tue, Apr 1, 2008 at 8:50 PM, Kilbride, James P.
<James.Kilbride at gd-ais.com> wrote:
> Antti, can you provide an example showing this? Easy to say, better to
>  see a code example.

Sure, here goes:

    Solar_Registry::set(
        'sql2',
        Solar::factory(
            'Solar_Sql',
            array(
                // config for sql2
            )
        )
    );

Ok now you can tell in your config file that, say,
Solar_Auth_Adapter_Sql should use 'sql2' for it's SQL access.

    $config['Solar_Auth_Adapter_Sql']['sql'] = 'sql2';

If you use the version of Solar in SVN, you could do this in your
config file (not a single line of code needed):

    $config['Solar']['registry_set']['sql2'] = array(
        'Solar_Sql',
        array(
            // config for the other connection
        )
    );

    $config['Solar_Auth_Adapter_Sql']['sql'] = 'sql2';

This would create a registry entry for the other connection
automatically when Solar starts up.

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


More information about the Solar-talk mailing list