略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: PDO_INFORMIX DSN

2024-12-22

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.

范例

示例 #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

示例 #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");
add a noteadd a note

User Contributed Notes 3 notes

up
3
andres at wookplay dot com
4 years ago
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);

?>
up
-15
phanx at phanx dot com
12 years ago
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.
up
-11
mchennaoui at cpm dot co dot ma
4 years ago
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.

官方地址:https://www.php.net/manual/en/ref.pdo-informix.connection.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3