PDO_INFORMIX DSN

(PECL PDO_INFORMIX >= 0.1.0)

PDO_INFORMIX DSNConnecting to Informix databases

˵Ã÷

The PDO_INFORMIX Data Source Name (DSN) is based on the Informix ODBC DSN string. Details on configuring an Informix ODBC DSN are available from the » Informix Dynamic Server Information Center. The major components of the PDO_INFORMIX DSN are:

DSN prefix

The DSN prefix is informix:.

DSN

The DSN can be either a data source setup using odbc.ini or a complete » connection string.

·¶Àý

Example #1 PDO_INFORMIX DSN example using odbc.ini

The following example shows a PDO_INFORMIX DSN for connecting to an Informix database cataloged as Infdrv33 in odbc.ini:

$db = new PDO("informix:DSN=Infdrv33", "", "");
[ODBC Data Sources]
Infdrv33=INFORMIX 3.3 32-BIT

[Infdrv33]
Driver=/opt/informix/csdk_2.81.UC1G2/lib/cli/iclis09b.so
Description=INFORMIX 3.3 32-BIT
Database=common_db
LogonID=testuser
pwd=testpass
Servername=ids_server
DB_LOCALE=en_US.819
OPTIMIZEAUTOCOMMIT=1
ENABLESCROLLABLECURSORS=1

Example #2 PDO_INFORMIX DSN example using a connection string

The following example shows a PDO_INFORMIX DSN for connecting to an Informix database named common_db using the Informix connection string syntax.

$db = new PDO("informix:host=host.domain.com; service=9800;
    database=common_db; server=ids_server; protocol=onsoctcp;
    EnableScrollableCursors=1", "testuser", "tespass");

User Contributed Notes

andres at wookplay dot com 27-Dec-2017 08:38
Example #2 PDO_INFORMIX DSN example using a connection string

To work properly, the DSN connection string must not have line breaks.

<?php

$conexion
= new PDO("informix:host=host.domain.com; service=9800;
    database=common_db; server=ids_server; protocol=onsoctcp;
    EnableScrollableCursors=1"
, "testuser", "tespass");

   
$sql    = "SELECT * FROM test";
   
$prep   = $conexion->prepare($sql);
   
$prep->execute();
   
$result = $prep->fetchAll(PDO::FETCH_ASSOC);

   
var_dump($result);

?>
mchennaoui at cpm dot co dot ma 06-Nov-2017 03:40
Bonjour

J'ai appliqu¨¦ la proc¨¦dure compil¨¦, install¨¦ et charger le php_pdo_inkformix et j'ai utilis¨¦ la chaine de connexion suivant :

$bd = new PDO("informix:host=srvinf; service=1526;database=base; server=ol_test; protocol=onsoctcp;EnableScrollableCursors=1", "test", "test");

apr¨¨s ¨¦x¨¦cution du fichier connexion.php j'ai eu l'erreur :

- Fatal error: Uncaught exception 'PDOException' with message 'could not find driver' in C:\wamp\www\Tests\informix.php on line 5

-PDOException: could not find driver in C:\wamp\www\Tests\informix.php on line 5

Merci de m'assister svp.
phanx at phanx dot com 07-Jan-2010 01:56
When connect to the Dynamic Informix Server, got this error log in apache's error log file:

[Wed Dec 30 12:44:11 2009] [error] [client 1.1.1.1] PHP Fatal error:  Uncaught exception 'PDOException' with message 'SQLSTATE=HY000, SQLDriverConnect: -11005 [Informix][Informix ODBC Driver]Unspecified System Error =  -11005.' in /opt/webroot/informix.php:5\nStack trace:\n#0 /opt/webroot/informix.php(5): PDO->__construct('informix:host=l...', 'username', 'password')\n#1 {main}\n  thrown in /opt/webroot/informix.php on line 5

you should export correct INFORMIXDIR enviroment variable for root user and restart the web server.

and another error:
 
[Wed Dec 30 13:10:10 2009] [error] [client 1.1.1.1] PHP Fatal error:  Uncaught exception 'PDOException' with message 'SQLSTATE=01S00, SQLDriverConnect: -11005 [Informix][Informix ODBC Driver]Invalid connection string attribute.' in /opt/webroot/informix.php:5\nStack trace:\n#0 /opt/webroot/informix.php(5): PDO->__construct('informix:host=l...', 'username', 'password')\n#1 {main}\n  thrown in /opt/webroot/informix.php on line 5

you should let your connection string in one line, without line feed.