Accessing multiple DB2 instances using php->odbc_*
Posted: Tue Feb 28, 2006 10:16 am
I am working with two DB2 instances on an AIX 5.2 machine, one of which has multiple local databases cataloged, and another one has local databases and also an AS/400 databases cataloged remotely through DB2 Connect.
I have compiled PHP to work with the DB2 Connect client and I have confirmed that I am able to connect to all of these databases through php, and even to multiple databases on the same DB2 instance (using PHP-CLI scripts). Here is the problem:
I am unable to connect to databases across the two DB2 instances within a single application run (e.g. using PHP-CGI with apache module). I can create two php programs one connecting to a db on one instance, and one connecting to a db in the other. However, I am unable to combine the run into one program, leading me to believe that db2 can "attach" one and only one instance to a process (I am currently using the putenv("DB2INSTANCE=$instance") technique). Googling, I could find nothing about how to re-attach instances, indeed I found that once attached it is apparently impossible to re-attach (see link below).
Here is the closest result google returned (after scrolling a while through multiple searches): http://dbforums.com/t366790.html which talks about switching contexts (gives c code)...
My ultimate question is: how do I access multiple DB2 instances in php? My main php environment is apache module (this is how my users use my deliverables). Is pcntl_fork an avenue? What about these context switches? Is there something trivial that I am missing?
Thank you all for this site, and in advance for your time,
phil
I have compiled PHP to work with the DB2 Connect client and I have confirmed that I am able to connect to all of these databases through php, and even to multiple databases on the same DB2 instance (using PHP-CLI scripts). Here is the problem:
I am unable to connect to databases across the two DB2 instances within a single application run (e.g. using PHP-CGI with apache module). I can create two php programs one connecting to a db on one instance, and one connecting to a db in the other. However, I am unable to combine the run into one program, leading me to believe that db2 can "attach" one and only one instance to a process (I am currently using the putenv("DB2INSTANCE=$instance") technique). Googling, I could find nothing about how to re-attach instances, indeed I found that once attached it is apparently impossible to re-attach (see link below).
Here is the closest result google returned (after scrolling a while through multiple searches): http://dbforums.com/t366790.html which talks about switching contexts (gives c code)...
My ultimate question is: how do I access multiple DB2 instances in php? My main php environment is apache module (this is how my users use my deliverables). Is pcntl_fork an avenue? What about these context switches? Is there something trivial that I am missing?
Thank you all for this site, and in advance for your time,
phil