Inspired by https://github.com/joanrivera/docker-informixpdo
DISCLAIMER: I'm archiving this repo as I never managed to make the PHP PDO driver work correctly 100% of the time.
The handling of locales and character encoding with this DBMS is stupid. String to date conversions don't always support ISO format, diacritics are mangled, and when you fix the diacritics you end up with CHAR fields padded with garbage instead of whitespace.
On the other hand, the JDBC driver works just fine, so if you can use a “bridge” like this one instead of connecting directly from PHP, just use a JEE based service.
For example: https://github.com/vctls/jdbc-informix-bridge
Base configuration files to generate a Docker container with PHP, Apache and PDO_Informix support.
This is a proof of concept on how to compile and install PDO_Informix with the IBM Informix SDK.
It provides a very crude web API to which you can send SQL queries and retrieve the results in JSON format.
⚠ WARNING: Queries are executed literally. This provides no security whatsoever.
You can either pull the image from the Docker hub or build it yourself as follows.
-
Clone the project.
-
CSDK and the PDO souce code are versioned through Git LFS, but if for some reason you need to donwload them manually, backup links are below. Put both into the
informix
directory:- The Informix Client SDK, from the IBM website (as of 2019-01-15):
Tested with version 4.10.FC9DE.LINUX for x86-64 architecture.
https://www-01.ibm.com/marketing/iwm/iwm/web/pickUrxNew.do?source=ifxdl
(requires login. See below.) - The PDO sources from
pecl.php.net
:
Tested with version 1.3.3.
https://pecl.php.net/package/PDO_INFORMIX
- The Informix Client SDK, from the IBM website (as of 2019-01-15):
-
(Optional) In the
informix/slqhosts
file, change the stringdemo_server
to match your Informix server name. -
(Optional) Review the files in the
scripts
directory and edit according to your needs. Be sure to check the file names if you're not using the ones provided. -
Copy
.env.dist
into.env
and set your connection settings in that file.
Since the IBM site is a real PITA, has changed multiple times, requires an account, and we have no guarantee that these files won't disappear overnight, here's a direct link to a working version:
https://mega.nz/#!RZ4SEa5I!TUxX4ZP75g3jqyX0vlCVIjD_L_W7Kj3tpilpKn4tcMc
And here's a link to the PDO_informix source, just in case:
https://mega.nz/#!ZQ5DGYjA!J7ppK75hFd9PxsJ5Fsoc8n9s3IDRvhKxKzGQ-z8ZmA8
-
Build the image:
docker build -t ifxpdo .
-
When containers are to be created, note that you must set the Infomix server IP:
docker run -d -p 80:80 -v /var/www/html:/var/www/html --add-host ifxserver:192.168.0.2 ifxpdo
.
Run the project with docker-compose:
docker-compose up
Open localhost
in your browser to see if it's working.
You should see something like this:
[{"":"2019-07-31 14:28:29.160","0":"2019-07-12 14:28:29.160"}]
Declare the informix.local
domain for clarity.
You can pass SQL queries in get parameters as follows. The string must of course be URL encoded. Modern browsers will do that automatically.
http://informix.local/?query=SELECT * FROM systables WHERE tabid=:tabid¶ms[tabid]=1;
You can also pass the PDO fetch style through the fetch_style parameter.
Default is 2 (FETCH_ASSOC
).
http://informix.local/?query=SELECT * FROM systables WHERE tabid=:tabid¶ms[tabid]=1&fetch_style=3;