Tuesday, May 13, 2008

Informix meets wampserver 2

Ok, so here's the story. The easy part is getting the PDO_informix object turned on in Wampserver. You just need to click right click on the wampserver icon, go to PHP > PHP extensions > php_pdo_informix.

Then create a new php file, and type this:


<?php
$i=0;
try {
$db = new PDO(
"informix:host=it;service=1526;database=stores_demo;server=ol_it;
protocol=olsoctcp;EnableScrollableCursors=1;DB_LOCALE=EN_US.8859-1",
"informix",
"informix");
}
catch (PDOException $e) {
echo "Could not connect to Informix servr:\n" . $e->getMessage() . "\n";
}
?>

Source: http://www.ibmdatabasemag.com/showArticle.jhtml?articleID=191502698
On my system, the web browser will puke out an error:


Could not connect to Informix server: SQLSTATE=HY000, SQLDriverConnect: -23101 [Informix][Informix ODBC Driver][Informix]Unable to load locale categories.


which is eerily similar to the case where you try to use the iLogin demo that comes with the Informix installation.

Strange thing is if you tried Server Studio, you don't get the locale error.

The time now is 1715 and happily I write with a solution to my problem.
SOLUTION:

On WindowsXP, set the INFORMIXDIR and INFORMIXSERVER in Environment Variables. They should look like:


INFORMIXDIR = C:\Program Files\IBM\Informix\Connect
INFORMIXSERVER = ol_[computer name]


but should be a bit different for you if you installed Informix in a different folder.
See the screenshot below for my trophy. PHP connects to the demo database stores_demo. I did a simple "SELECT * FROM customer" query.



What else did I try but did not work?


SetEnv INFORMIXDIR C:\Program Files\Informix
SetEnv INFORMIXSERVER ol_it


I placed these two in httpd.conf and restarted the server. They did appear in Apache Environment but it is not what I need. I need it to appear in Environment.

The running ol_[computer name] batch file in Start Menu > Informix Dynamic Server 9.40 ol_[computer name]. It gives you the illusion that the environments are set, but aren't.

Some useful links for reference, http://www.ffnn.nl/pages/articles/linux/vmware-player-image-creation.php
to create empty vmware disks. You don't really need VM Workstation anymore.

No comments: