Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

connect to 2 DBs/2 informix servers to execute sql

Status
Not open for further replies.

keenamateur

Technical User
Joined
Jan 16, 2003
Messages
2
Location
AT
i have succeeded to connect to an informix db, run queries, and return the results as required.

could anyone advise how to accomplish a simultaenous connect to run a query against two DBs on two ifx servers in php? (using php.exe on w2k)

any help greatly appreciated
 
I'm not sure exactly what you mean by "simultaneous connect".

You should be able to run ifx_connect() twice, once to connect to each server, and store the connection handles in variables.

Then use the individual db-connect handles stored in their appropriate variables to query the servers.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
thanks sleipnir214 for your feedback - i have to admit though that i did not fully understand what is meant with "...then use individual db-connect handles ....to query....".
below i put some code typical of what i would like to accomplish - assuming that tbl_a is on server1 and tbl_b on server2 could you possibly point me in the right direction?

...
$conn1 = ifx_connect("server1", "user1", "passwd1") or die("bye");
$conn2 = ifx_connect("server2", "user2", "passwd2") or die("bye");

$sql =
"select tbl_a.fld_1, tbl_a.fld_2, tbl_b.fld_1
from tbl_a, outer tbl_b
where tbl_a.fld_1 = tbl_b.fld_1"

??? $sql_result = ifx_query($sql,$conn1) or die("bye");

ifx_htmltbl_result($sql_result,"border=0");
ifx_free_result ($sql_result);
ifx_close($conn1);
...

how would the line with the definition of $sql_result have to be changed to reflect that the sql uses both connection vars? or am i on a completely wrong track?
 
PHP isn't going to do what you're trying to do. I doubt any programming language can. Joins must be handled within a database server, not by a programming language. I'm not familiar at all with Informix. Can it perform joins to tables that do not reside on that server?

What I was talking about is creating individual connections to the two servers, then querying one server for some data, then using that fetched data to create queries to be sent to the second server.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top