1
votes

I have the issue, to get a PHP script connecting to an Informix DB. I thought installing the Zend-server community edition and in addition the pdo_informix extension. When I run the Zend-server admin in the browser, I see the pdo_informix extension marked as "green". Afterwards I've installed the Informix ClientSDK 3.70 on Ubuntu. I've set the $INFORMIXDIR environment variable into /etc/profile and into the PATH variable to the bin directory. The installation dir was /opt/IBM/informix . When I now try to write code in PHP like

try{

 $db = new PDO("informix:host=xx.xx.com;database=xxx;server=xxx_net; protocol=onsoctcp;", databaseuser, databasepassword);
 $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
 echo "test";

}catch (PDOException $e){

 echo "<br/>Failed: ". $e->getMessage()."<br/>";
}

I've got the following error in the browser:

Failed: SQLSTATE=HY000, SQLDriverConnect: -23101 [Informix]
   [Informix ODBC Driver][Informix]Unspecified System Error = -23101.

If I'm trying to connect with the Server Studio on Ubuntu to the Informix DB it works well, but I guess they are using the JDBC driver.

If I go to the bin directory of my Informix clientsdk, there is an application called finderr. If I do a finderr -23101 I get the following output:

./finderr -23101
-23101 Unable to load locale categories.

So i thought that I have to set the DB_LOCALE, CLIENT_LOCALE environment variables... my server is using en_us.819 and my client is using en_us.utf8 .

2

2 Answers

2
votes

Being unable to load locale categories normally means that either INFORMIXDIR is not set for the software trying to access the Informix locale data (which is found in $INFORMIXDIR/gls), or that the locale categories are unspecified or mis-specified. These are classically the environment variables CLIENT_LOCALE and DB_LOCALE, which have values such as 'en_us.8859-1' (the default) or 'es_es.utf8' (Spanish in Spain using UTF-8).

I would concentrate on ensuring that the browser has the environment set correctly. It may depend on how you launch it.

There are some other environment variables that could be used - DBLANG, LANG, and the LC_* set of names. However, they are unlikely to be needed if CLIENT_LOCALE and DB_LOCALE are set. With that said, I've recently found that with Informix 4GL (I4GL), some code written with Japanese characters in things like table names would not compile unless DBLANG was set as well as the *LOCALE variables. However, the LC* and LANG variables seemed to have minimal to no effect on the result.

0
votes

You probably have to set LD_LIBRARY_PATH. I do it with:

export LD_LIBRARY_PATH=$INFORMIXDIR/lib/:$INFORMIXDIR/lib/cli:$INFORMIXDIR/lib/esql:
export PATH=$INFORMIXDIR/bin:$INFORMIXDIR/lib:/usr/local/bin:/usr/bin:/bin

If that will not help then you can try with unixODBC. It seems that PHP uses some kind of ODBC. In unixODBC online manuals there is article about connecting to Informix - read it. Use isql (interactive SQL) unixODBC tool to connect to configured ODBC database.

If isql cannot connect to database with the same error then you can use strace to see what library the ODBC driver cannot load.