PHP  
downloads | documentation | faq | getting help | | php.net sites | links 
search for in the  
previousimap_utf8ifx_affected_rowsnext
Last updated: Tue, 28 May 2002
view this page in Printer friendly version | English | Brazilian Portuguese | Czech | Dutch | French | German | Hungarian | Italian | Japanese | Korean | Polish | Romanian | Russian | Spanish | Turkish

XLIV. Informix functions

Introduction

The Informix driver for Informix (IDS) 7.x, SE 7.x, Universal Server (IUS) 9.x and IDS 2000 is implemented in "ifx.ec" and "php3_ifx.h" in the informix extension directory. IDS 7.x support is fairly complete, with full support for BYTE and TEXT columns. IUS 9.x support is partly finished: the new data types are there, but SLOB and CLOB support is still under construction.

Requirements

Configuration notes: You need a version of ESQL/C to compile the PHP Informix driver. ESQL/C versions from 7.2x on should be OK. ESQL/C is now part of the Informix Client SDK.

Make sure that the "INFORMIXDIR" variable has been set, and that $INFORMIXDIR/bin is in your PATH before you run the "configure" script.

Installation

Huomaa: The configure script will autodetect the libraries and include directories, if you run configure --with_informix=yes. You can override this detection by specifying "IFX_LIBDIR", "IFX_LIBS" and "IFX_INCDIR" in the environment. The configure script will also try to detect your Informix server version. It will set the "HAVE_IFX_IUS" conditional compilation variable if your Informix version >= 9.00.

Runtime Configuration

Huomaa: 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 the PATH. 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_LINBRARY_PATH or ld.so.conf/ldconfig).

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").

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".

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.

Predefined Constants

T�m� laajennus ei m��rittele yht�k��n vakiota.

Sis�llys
ifx_affected_rows -- Get number of rows affected by a query
ifx_blobinfile_mode -- Set the default blob mode for all select queries
ifx_byteasvarchar -- Set the default byte mode
ifx_close -- Close Informix connection
ifx_connect -- Open Informix server connection
ifx_copy_blob -- Duplicates the given blob object
ifx_create_blob -- Creates an blob object
ifx_create_char -- Creates an char object
ifx_do --  Execute a previously prepared SQL-statement
ifx_error -- Returns error code of last Informix call
ifx_errormsg -- Returns error message of last Informix call
ifx_fetch_row -- Get row as enumerated array
ifx_fieldproperties -- List of SQL fieldproperties
ifx_fieldtypes -- List of Informix SQL fields
ifx_free_blob -- Deletes the blob object
ifx_free_char -- Deletes the char object
ifx_free_result -- Releases resources for the query
ifx_get_blob -- Return the content of a blob object
ifx_get_char -- Return the content of the char object
ifx_getsqlca --  Get the contents of sqlca.sqlerrd[0..5] after a query
ifx_htmltbl_result --  Formats all rows of a query into a HTML table
ifx_nullformat --  Sets the default return value on a fetch row
ifx_num_fields -- Returns the number of columns in the query
ifx_num_rows -- Count the rows already fetched from a query
ifx_pconnect -- Open persistent Informix connection
ifx_prepare -- Prepare an SQL-statement for execution
ifx_query -- Send Informix query
ifx_textasvarchar -- Set the default text mode
ifx_update_blob -- Updates the content of the blob object
ifx_update_char -- Updates the content of the char object
ifxus_close_slob -- Deletes the slob object
ifxus_create_slob -- Creates an slob object and opens it
ifxus_free_slob -- Deletes the slob object
ifxus_open_slob -- Opens an slob object
ifxus_read_slob -- Reads nbytes of the slob object
ifxus_seek_slob -- Sets the current file or seek position
ifxus_tell_slob -- Returns the current file or seek position
ifxus_write_slob -- Writes a string into the slob object
User Contributed Notes
Informix functions
add a note about notes

10-Apr-2000 10:28

installing with IFS2000 support found required header files in
/opt/informix/incl/esql, but the files were actually in
/opt/informix/incl/public.  a quick change to the configure file fixed
that.


26-Sep-2000 01: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.


02-Mar-2001 10: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.


27-Jul-2001 05: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  .


15-Nov-2001 10: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.


27-May-2002 01: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

add a note about notes
previousimap_utf8ifx_affected_rowsnext
Last updated: Tue, 28 May 2002
show source | credits | stats | mirror sites:  
Copyright © 2001, 2002 The PHP Group
All rights reserved.
This mirror generously provided by:
Last updated: Sat Jul 6 04:18:21 2002 CEST