downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

ifx_affected_rows> <imap_utf8
[edit] Last updated: Mon, 01 Nov 2010

view this page in

LXIV. Informix 関数

導入

Informix (IDS) 7.x, SE 7.x, Universal Server (IUS) 9.x ,IDS 2000 用の Informix ドライバは、informix 拡張機能用ディレクトリの "ifx.ec" および "php3_ifx.h" に実装されています。 IDS 7.x のサポートは BYTE および TEXT カラムを完全にサポートしており、 完成度はかなり高いです。 IUS 9.x のサポートは部分的に完成しています。つまり、 新しいデータ型はサポートされていますが、SLOB および CLOB のサポートについてはまだ作業中です。

要件

設定に関する注意: PHP Informix ドライバをコンパイルするには、ESQL/C が必要です。 7.2x 以降のバージョンに付属する ESQL/C は問題なく使用できます。 現在では、ESQL/C は Informix クライアント SDK に含まれています。

"configure" スクリプトを実行する前に、必ず "INFORMIXDIR" 変数を 設定し、PATH に $INFORMIXDIR/bin を設定しておいてください。

インストール手順

このモジュールで定義した関数を使用可能とするには、configure に --with_informix[=DIR] を指定して PHP インタプリタをコンパイルする必要があります。ただし、DIR は Informix のベースインストールディレクトリで、デフォルトはありません。

実行時設定

php.ini の設定により動作が変化します。

注意: Informix 用環境変数 INFORMIXDIR および INFORMIXSERVER が PHP ifx ドライバで利用可能であり、INFORMIX のバイナリがあるディレクトリに パスが通っていることを確認してください。テストを始める前に phpinfo() と書いたスクリプトを実行し、 これを確認してください。 phpinfo() があるスクリプトは、これらの環境変数の 一覧を出力します。これは、CGI 版の PHP および Apache mod_php で 共に行われます。これらの環境変数は Apache のスタートアップスクリプトで 設定する必要があります。

また、Informix 共有ライブラリがローダーで利用可能である必要があります (LD_LINBRARY_PATH または ld.so.conf/ldconfig を確認してください)。

BLOB (TEXT および BYTE カラム)の使用に関する注意: 通常、BLOB は BLOB ID により指定されます。 select クエリは、BYTE および TEXT カラム毎に "blob id" を返します。 ("ifx_blobinfile(0);" により) メモリー上で BLOB を得ることを選択した場合、 "string_var = ifx_get_blob($blob_id);" で内容を得ることができます。 BLOB カラムの内容をファイルに取得したい場合、 "ifx_blobinfile(1);" を使用してください。 "ifx_get_blob($blob_id);" によりファイル名を得ることができます。 BLOB の内容を得る際には、通常のファイル入出力を行ってください。

insert/update クエリーに関しては、 "ifx_create_blob();" により自分で "blob id" を作成する必要があります。 その後、blob id を配列に代入し、 クエリー文字列の中の blob カラムを疑問符 (?) で置換します。 updates/inserts の場合、ifx_update_blob() で blob の内容を設定するのが便利でしょう。

BLOB カラムの動作は、設定用変数で変更することができます。 これらの変数は、実行時にも設定可能です。

設定変数 : ifx.textasvarchar

設定変数 : ifx.byteasvarchar

ランタイム関数 :

ifx_textasvarchar(0) : TEXT カラムを有する select クエリーに blob id を使用する

ifx_byteasvarchar(0) : BYTE カラムを有する select クエリーに blob id を使用する

ifx_textasvarchar(1) : TEXT カラムを VARCHAR カラムとして返します。 このため、select クエリにおいて blob id を使用する必要はありません。

ifx_byteasvarchar(1) : BYTE カラムを VARCHAR カラムとして返します。 このため、select クエリにおいて blob id を使用する必要はありません。

設定変数 : ifx.blobinfile

ランタイム関数 :

ifx_blobinfile_mode(0) : メモリに BYTE カラムを返し、blob id によりその内容を取り出す

ifx_blobinfile_mode(1) : メモリに BYTE カラムを返し、blob id によりそのファイル名を取り出す

ifx_text/byteasvarchar を 1 に設定した場合、 通常の(しかしやや長い) VARCHAR フィールドのように select クエリーで TEXT や BYTE カラムを使用することが可能です。 全ての文字列は、PHP で "数えられる" ので、これにより、 "バイナリ・セーフ"が維持されます。 これを正しく処理するのはあなた次第です。 返されるデータには何でも含むことができますが、その内容について 責任を負うことになります。

ifx_blobinfile を 1 に設定した場合、blob の内容を得るために ifx_get_blob(..) により返されたファイル名を使用してください。 この場合、行を取得する際に「Informix により作成された テンポラリファイルを削除する」責任があります。 取得された新規の行は、BYTE カラム毎に新規のテンポラリファイルを 作成します。

テンポラリファイルの位置は、環境変数 "blobdir" により設定することが できます。デフォルトは、"." (カレントディレクトリ)です。 putenv(blobdir="tmpblob"); のようにすることにより、誤って残って しまったテンポラリファイルを削除することが容易になります (テンポラリファイルの名前は "blb" で始まります)。

自動的に "char" (SQLCHAR および SQLNCHAR) データを取り去る: これは、次の設定変数により設定することが可能です。

ifx.charasvarchar : 最後尾のスペースを何らかの削除処理を行わずに 自動的に取り去る場合に 1 に設定します。

NULL 値: 設定変数 ifx.nullformat (およびランタイム関数 ifx_nullformat()) を TRUE に設定した場合、文字列 "NULL" として NULL カラムを返します。FALSE に設定した場合は 空文字列を返します。これにより、NULL カラムと空のカラムを識別することが 可能となります。

表 1. Informix 設定オプション

名前デフォルト変更の可否変更履歴
ifx.allow_persistent"1"PHP_INI_SYSTEM 
ifx.max_persistent"-1"PHP_INI_SYSTEM 
ifx.max_links"-1"PHP_INI_SYSTEM 
ifx.default_hostNULLPHP_INI_SYSTEM 
ifx.default_userNULLPHP_INI_SYSTEM 
ifx.default_passwordNULLPHP_INI_SYSTEM 
ifx.blobinfile"1"PHP_INI_ALL 
ifx.textasvarchar"0"PHP_INI_ALL 
ifx.byteasvarchar"0"PHP_INI_ALL 
ifx.charasvarchar"0"PHP_INI_ALL 
ifx.nullformat"0"PHP_INI_ALL 
PHP_INI_* 定数の詳細および定義については 付録G を参照してください。

以下に設定ディレクティブに関する 簡単な説明を示します。

ifx.allow_persistent boolean

持続的な Informix 接続を可能とするかどうか。

ifx.max_persistent integer

プロセス毎の持続的 Informix 接続の最大数。

ifx.max_links integer

持続的接続を含むプロセス毎の Informix 接続の最大数。

ifx.default_host string

ifx_connect() または ifx_pconnect() において、ホストが指定されない 場合のデフォルトのホスト。 セーフモード では適用されません。

ifx.default_user string

ifx_connect() または ifx_pconnect() において、 ユーザが指定されない場合のデフォルトのユーザ。 セーフモード では適用されません。

ifx.default_password string

ifx_connect() または ifx_pconnect() において、 パスワードが指定されない場合のデフォルトのパスワード。 セーフモード では適用されません。

ifx.blobinfile boolean

blob カラムをファイルに返したい場合には TRUE を指定します。 メモリ内に返したい場合には FALSE を指定します。 ifx_blobinfile_mode() により、実行時にこの設定を 上書きすることができます。

ifx.textasvarchar boolean

select 文において TEXT カラムを通常の文字列として返したい場合は TRUE を指定し、blob id パラメータを使用したい場合は FALSE を指定します。 ifx_textasvarchar() により、実行時にこの設定を 上書きすることができます。

ifx.byteasvarchar boolean

select 文において BYTE カラムを通常の文字列として返したい場合は TRUE を指定し、blob id パラメータを使用したい場合は FALSE を指定します。 ifx_byteasvarchar() により、実行時にこの設定を 上書きすることができます。

ifx.charasvarchar boolean

取得時に CHAR カラムから末尾の空白を取り除きたい場合に TRUE を指定してください。

ifx.nullformat boolean

リテラル文字列 "NULL" として NULL カラムを返したい場合に TRUE、 空の文字列として返したい場合は FALSE を指定してください。 ifx_nullformat() により、実行時にこの設定を 上書きすることができます。

定義済み定数

定数は定義されていません。

目次
ifx_affected_rows -- クエリで変更された行の数を得る
ifx_blobinfile_mode --  全ての select クエリに関するデフォルトの BLOB モードを設定する
ifx_byteasvarchar -- デフォルトのバイトモードを設定する
ifx_close -- Informix 接続を閉じる
ifx_connect -- Informix サーバへの接続をオープンする
ifx_copy_blob -- 指定した BLOB オブジェクトを2重化する
ifx_create_blob -- BLOB オブジェクトを作成する
ifx_create_char -- 文字オブジェクトを作成する
ifx_do -- 事前に準備された SQL 文を実行する
ifx_error -- 直近の Informix コールのエラーコードを返す
ifx_errormsg -- 直近の Informix コールのエラーメッセージを返す
ifx_fetch_row -- 配列として行を得る
ifx_fieldproperties -- SQL フィールドプロパティのリスト
ifx_fieldtypes -- Informix SQL フィールドのリスト
ifx_free_blob -- BLOB オブジェクトを削除する
ifx_free_char -- 文字オブジェクトを削除する
ifx_free_result -- クエリに関するリソースを解放する
ifx_get_blob -- BLOB オブジェクトの内容を返す
ifx_get_char -- 文字オブジェクトの内容を返す
ifx_getsqlca -- クエリ実行後、sqlca.sqlerrd[0..5] の値を得る
ifx_htmltbl_result --  クエリ結果の全行を HTML テーブルにフォーマットする
ifx_nullformat -- 取得する行のデフォルトの返り値を設定する
ifx_num_fields -- クエリのカラム数を返す
ifx_num_rows -- クエリから既に取得された行の数を数える
ifx_pconnect -- 持続的 Informix 接続をオープンする
ifx_prepare -- SQL 文を実行用に準備する
ifx_query -- Informix クエリを送信する
ifx_textasvarchar -- デフォルトのテキストモードを設定する
ifx_update_blob -- BLOB オブジェクトの内容を更新する
ifx_update_char -- 文字オブジェクトの内容を更新する
ifxus_close_slob -- SLOB オブジェクトを削除する
ifxus_create_slob -- SLOB オブジェクトを作成し、オープンする
ifxus_free_slob -- SLOB オブジェクトを削除する
ifxus_open_slob -- SLOB オブジェクトをオープンする
ifxus_read_slob -- SLOB オブジェクトから n バイト読みこむ
ifxus_seek_slob -- 現在のファイル位置またはシーク位置を返す
ifxus_tell_slob -- カレントのファイルまたはシーク位置を返す
ifxus_write_slob -- SLOB オブジェクトに文字列を書きこむ


ifx_affected_rows> <imap_utf8
[edit] Last updated: Mon, 01 Nov 2010
 
add a note add a note User Contributed Notes Informix 関数
roger at wzero dot com dot br 01-Mar-2007 06:41
Unfortunately the informix extension has been moved to PECL but has no maintainer.
http://devzone.zend.com/node/view/id/1621#Heading11

In practic terms, it has been moved but is not available in PECL yet.

It's sad. I have a big client who uses this extension for more than 6 years and now has to change a code base of 500,000 lines of code or install an old version of PHP in the new server. They recently bought a redundant, double cpu, 8 gb ram, scsi disk server and will not be happy to run old versions of software with unmaintained extensions.
HowY 09-Feb-2007 08:58
One very frustrating experience with interfacing
Informix and unixODBC (on RHEL4 - PHP 5.20)
was the constant Informix error:
[SQLSTATE=IX 001 SQLCODE=-1829]
Unable to load locale categories
& the non existant handles from unixODBC calls.

This is an issue of the environment being set correctly
which I thought was - phpinfo() reported that the apache
environment was correct <_server=> I even went as far as
to Put/Setenv in httpd.conf. 
The hint is in the php 'environment' block
 - it did not contain the env strings.

The fix was to insert the environment strings in the httpd
start-up script (/etc/init.d/httpd) which pushed the
 environment correctly when the server starts up.

Hope to save someone else the hours....
Ian McMurray 15-Apr-2005 01:02
Installation on RedHat Fedore Core (or in that matter any Linux OS which has a version of glibc  of 2.3.* ~or above~) will need to have the latest Informix CSDK (downloadable from IBM). 2.90.UC1.LINUX at the time of this post.

http://www-306.ibm.com/software/data/informix/tools/connect/

I was unable to make PHP with v2.80 of the csdk (as it complained about mktemp being dangerous and how ctype was undefined. After downloading csdk 2.90, I was able to make PHP with no problems at all. (--with-informix).

There goes 2 days of my life!

Feel free to drop me an email at ian_at_devtonic_dot_com if you have any questions.
drsound 31-Oct-2004 10:20
I just wrote a mini-HOWTO about adding Informix support to mod_php running on a Gentoo Linux server (x86). I wanted to post it here but it was too long. You can find it on http://forums.gentoo.org/viewtopic.php?t=245249 (just in case for some reason they change the thread number, the title is "HOWTO: PHP Informix client support").
jeff at domintcom dot com 26-Oct-2002 11:06
add the following to /etc/profile (right before unset i (adjust to your needs)

export INFORMIXDIR=/opt/informix
export ODBCINI=/usr/local/etc/odbc.ini
export INFORMIXSERVER=m_srv

then add the following to your httpd.conf

PassEnv INFORMIXDIR
PassEnv ODBCINI
PassEnv INFORMIXSERVER

(or you can use SetEnv SetEnv INFORMIXDIR /opt/informix  etc.)
cornecNOSPAM at reach dot NO_SPAM dot com 15-Oct-2002 08:14
I upgraded to csdk-2.70.UC3-1 and got the following error when trying to start apache:

Syntax error on line 205 of /usr/local/apache/conf/httpd.conf:
Cannot load /usr/local/apache/libexec/libphp4.so into server: /opt/informix/lib/esql/libifgen.so: undefined symbol: stat
/usr/local/apache/bin/apachectl start: httpd could not be started

This machine has glibc 2.3.5

The following fixed the problem for me (surely there's a better fix) but i'm not sure how it might affect other programs linked to libifgen

mkdir /tmp/ifx
cd /tmp/ifx
ar x $INFORMIXDIR/lib/esql/libifgen.a
gcc -shared -o libifgen.so *.o
cp libifgen.so $INFORMIXDIR/lib/esql
programacion at afinformatica dot com 27-May-2002 07:38
I have compile php-4.0.6 with informix support (dynamic) and when I try to
start apache, it gives me this error message:

Syntax error on line 246 of /etc/httpd/httpd.conf:
Cannot load /usr/lib/apache/libphp4.so into server: /home/informix7/lib/esql/lib
ifgen.so: undefined symbol: stat
/usr/sbin/apachectl start: httpd could not be started
isaac dot hopley at morton-fraser dot NO_SPAM dot com 15-Nov-2001 04:54
If you are tring to access an Informix Online 5.x server over the
network (ie from a webserver) using PHP, be aware that Online
doesn't support network communications as standard unlike later versions.

You need the Informix product 'I-Star' on your Online server.
This will allow your webserver with the informix client SDK
installed to communicate natively (ESQL).

Thanks go to Mario @ PRS for this info.
old dot wolf at project-w dot com 26-Jul-2001 11:40
An intermittent SQL error -25580 is caused by using the wrong glibc version in Linux.

I have this working correctly in Linux (x86) with Informix Client SDK for 2.70UC-1 for Linux, with glibc 2.1.3.

Originally I had glibc 2.1.1 (Red Hat 6), which gave the intermittent error, but upgrading glibc fixed it.

The Informix Client SDKs can be downloaded from www.informix.com (you need to own an Informix database to log on), and glibc is at ftp://ftp.gnu.org/gnu/glibc .
MarkRoedel at letu dot edu 02-Mar-2001 04:19
There's also a FreeBSD version of the client libraries that'll work with PHP.  It's not available for download from their website, but you can request a copy (cd or electronic delivery) by calling Informix Customer Support at 1-800-274-8184 option 3.

Some customer service reps know more about alternative operating systems than others, so you may have to do a bit of educating before they can locate the product in their database, but it's definitely there.

My e-mail confirmation referred to it as "Orderable Part Number 100-15871-204057-1", although that number may be specific to the electronically-delivered edition.
robernet at music-images dot com 26-Sep-2000 07:29
Verify with phpinfo() that you have informix module compiled in php.
Also verify that env vars INFORMIXDIR, INFORMIXSERVER, LD_LIBRARY_PATH are set, and that PATH have a route to your informix subdir.

 
show source | credits | sitemap | contact | advertising | mirror sites