• 首页
  • vue
  • TypeScript
  • JavaScript
  • scss
  • css3
  • html5
  • php
  • MySQL
  • redis
  • jQuery
  • 位置: php 中文手册 -> php 外部扩展库

    Informix数据库

    Note: 配置信息
    您需要一个ESQL/C版本来编译PHP Informix驱动程序。7.2x版本的ESQL/C应该可以。ESQL/C现在是Informix客户机SDK的一部分。要编译 PHP Informix 驱动需要 ESQL/C 支持,最低版本是 ESQL/C 7.2x。现在 ESQL/C是 Informix 客户端开发工具(CSDK)的一部分。

    在运行 configure 之前,请确认环境变量 INFORMIXDIR 已经设置,环境变量 PATH 中包含 $INFORMIXDIR/bin。

    安装

    为使 PHP 解析器支持 Informix 模块,需要在编译 PHP 时加入选项 --with-informix[=DIR] , 其中的 DIR 指的是 Informix 的安装目录(INFORMIXDIR),默认是空。

    So, php_ifx.dll is not more supported, because the PECL site warnings "This package is not maintained".  I can't find the source-code to compile.
    Best try is the PDO Informix.
    
    For windows , apache server, php connect informix.       
    I have try 4 days and finally success with it.       
    My php env is apache 2.0, php 5.2, informix 09.40       
           
    1) download php_ifx.dll from php home page (search with pecl-5.2 Win32), put php_ifx.dll in your php extension dir , in my case c:\php\ext .        
    2) in php.ini add follows :        
    extension=php_ifx.dll       
    3) download informix cdsk 3.0TC for windows from ibm, install it and then run your php app which has informix connect operation, if apache server has a error dialog, then restart computer(because installation add a system variable path : C:\Program Files\IBM\Informix\Client-SDK\bin), after restart confirm this error not occure again. (in this step php page finally error  with "sqlstate = IX 000 sqlcode= -25560" because of informix server not set, we will solute it in next step)
    4) run C:\Program Files\IBM\Informix\Client-SDK\bin\setnet32.exe change the values by following       
        4)-1 Tab Server Information   
            IBM Informix Server : informix server name
            HostName : informix  server ip address
            Protocolname : onsoctcp
            ServiceName : informix server port
        4)-2 Host Information   
            Current Host : informix  server ip address
        then click OK    
    5) run your php app, then you can do any ifx_xxxxx informix db operation. (in windows apache env don't mind INFORMIXDIR var ect...)
    

    运行时配置

    这些函数的行为受php.ini中的设置影响。

    Note:

    Make sure that the Informix environment variables INFORMIXDIR and INFORMIXSERVER are available to the PHP ifx driver, and that the INFORMIX bin directory is in thePATH. Check this by running a script that contains a call to phpinfo() before you start testing. The phpinfo() output should list these environment variables. This is true for both CGI php and Apache mod_php. You may have to set these environment variables in your Apache startup script.

    The Informix shared libraries should also be available to the loader (check LD_LIBRARY_PATH or ld.so.conf/ldconfig).

    Note: Some notes on the use of BLOBs (TEXT and BYTE columns)

    BLOBs are normally addressed by BLOB identifiers. Select queries return a "blob id" for every BYTE and TEXT column. You can get at the contents with "string_var = ifx_get_blob($blob_id);" if you choose to get the BLOBs in memory (with: "ifx_blobinfile(0);"). If you prefer to receive the content of BLOB columns in a file, use "ifx_blobinfile(1);", and "ifx_get_blob($blob_id);" will get you the filename. Use normal file I/O to get at the blob contents.

    For insert/update queries you must create these "blob id's" yourself with "ifx_create_blob();". You then plug the blob id's into an array, and replace the blob columns with a question mark (?) in the query string. For updates/inserts, you are responsible for setting the blob contents with ifx_update_blob().

    The behaviour of BLOB columns can be altered by configuration variables that also can be set at runtime:

    configuration variable: ifx.textasvarchar

    configuration variable: ifx.byteasvarchar

    runtime functions:

    ifx_textasvarchar(0): use blob id's for select queries with TEXT columns

    ifx_byteasvarchar(0): use blob id's for select queries with BYTE columns

    ifx_textasvarchar(1): return TEXT columns as if they were VARCHAR columns, so that you don't need to use blob id's for select queries.

    ifx_byteasvarchar(1): return BYTE columns as if they were VARCHAR columns, so that you don't need to use blob id's for select queries.

    configuration variable: ifx.blobinfile

    runtime function:

    ifx_blobinfile_mode(0): return BYTE columns in memory, the blob id lets you get at the contents.

    ifx_blobinfile_mode(1): return BYTE columns in a file, the blob id lets you get at the file name.

    If you set ifx_text/byteasvarchar to 1, you can use TEXT and BYTE columns in select queries just like normal (but rather long) VARCHAR fields. Since all strings are "counted" in PHP, this remains "binary safe". It is up to you to handle this correctly. The returned data can contain anything, you are responsible for the contents.

    If you set ifx_blobinfile to 1, use the file name returned by ifx_get_blob(..) to get at the blob contents. Note that in this case YOU ARE RESPONSIBLE FOR DELETING THE TEMPORARY FILES CREATED BY INFORMIX when fetching the row. Every new row fetched will create new temporary files for every BYTE column.

    The location of the temporary files can be influenced by the environment variable "blobdir", default is "." (the current directory). Something like: putenv(blobdir=tmpblob"); will ease the cleaning up of temp files accidentally left behind (their names all start with "blb").

    Note: Automatically trimming "char" (SQLCHAR and SQLNCHAR) data

    This can be set with the configuration variable

    ifx.charasvarchar: if set to 1 trailing spaces will be automatically trimmed, to save you some "chopping".

    Note: NULL values

    The configuration variable ifx.nullformat (and the runtime function ifx_nullformat()) when set to TRUE will return NULL columns as the string "NULL", when set to FALSE they return the empty string. This allows you to discriminate between NULL columns and empty columns.

    Informix configuration options
    名字默认可修改范围更新日志
    ifx.allow_persistent"1"PHP_INI_SYSTEMRemoved in PHP 5.2.1.
    ifx.max_persistent"-1"PHP_INI_SYSTEMRemoved in PHP 5.2.1.
    ifx.max_links"-1"PHP_INI_SYSTEMRemoved in PHP 5.2.1.
    ifx.default_hostNULLPHP_INI_SYSTEMRemoved in PHP 5.2.1.
    ifx.default_userNULLPHP_INI_SYSTEMRemoved in PHP 5.2.1.
    ifx.default_passwordNULLPHP_INI_SYSTEMRemoved in PHP 5.2.1.
    ifx.blobinfile"1"PHP_INI_ALLRemoved in PHP 5.2.1.
    ifx.textasvarchar"0"PHP_INI_ALLRemoved in PHP 5.2.1.
    ifx.byteasvarchar"0"PHP_INI_ALLRemoved in PHP 5.2.1.
    ifx.charasvarchar"0"PHP_INI_ALLRemoved in PHP 5.2.1.
    ifx.nullformat"0"PHP_INI_ALLRemoved in PHP 5.2.1.