Once you've set up a UnixODBC connection to Informix (as described elsewhere, for example in http://www.unixodbc.org/), the following PHP code will access a database via its DSN:
<?php
// We must set these environment variables for Informix to work. Either
// do it here or in php.ini.
putenv("INFORMIXDIR=/usr/share/informix");
putenv("ODBCINI=/usr/local/unixODBC/etc/odbc.ini");
// Open up a connection to the database.
if (!($con = odbc_connect("CollectOh", "", "")))
echo "<p>Connection to CollectOh failed.</p>\n";
else
{
// Let's try enumerating all of the tables in the database (there ain't
// no "show tables" here).
if (($res = odbc_exec($con, "select * from SYSTABLES")))
{
echo "<p>\n";
odbc_result_all($res);
echo "</p>\n";
}
// Close up shop, like good dobies.
odbc_close($con);
}
?>