David Dyess II wrote:
> Hi,
>
> Is it possible to plug a query into the xaraya core,
using as much of
> the native Xaraya processing as possible, to query a
database other than
> the one defined in the config file? I've seen
configurations for drupal
> that allowed you to specifiy individual databases for
certain kinds of
> data, such as sessions, users, etc. I've been digging
through the core
> files and I think I have an idea of how it currently
works, but I didn't
> see an obvious hole I could plug in secondary
databases. I'm not
> switching to drupal so that isn't an option :P
>
> I'm not sure how much demand there may be for such a
feature. It could
> be useful for people using multisites.
>
> Thanks,
> David.D
In MySQL, you can access tables from other databases simply
by using
the database.table syntax. You can use this with the
existing Xaraya
DB connections as well (and in fact, that's how the DD
utilities can
deal with external database tables).
Another approach consists of requesting a new connection
from Xaraya,
and then re-using that connection for your queries to
another database.
# create the database connection and save the connection key
(id)
$myconn =& xarDBNewConn($args);
$mykey = $myconn->database_key;
xarVarSetCached('MyPrivateConnection','key',$mykey);
...
# somewhere else in the page processing, re-use that
connection again
$mykey = xarVarGetCached('MyPrivateConnection','key');
$myconn =& xarDBGetConn($mykey);
...
That's mainly interesting for modules requiring their own
separate
database access.
There's no provision in the Xaraya core to switch
connections for
regular Xaraya tables though - not sure if you'd still need
it with
the options above, but if so, feel free to submit a feature
request
Mike.
_______________________________________________
Xaraya_devel mailing list
Xaraya_devel xaraya.com
http:
//xaraya.com/mailman/listinfo/xaraya_devel
|