You can connect to a database on a different machine by specifying the appropriate parameters in the connect function. For example, mysql uses this function:
mysql_connect(<host>, <username>, <password>);
You aren't limited to using a database on the same machine. If it is on the same machine, just use "localhost" for the host.
I think you'll need to use the odbc extension to communicate with IBM DB2.
Take care,
Nik
http://www.bigaction.org/