Ingres extension for PHP


Contents

1. Introduction
2. Platform support
3. Function support
4. Installing the extension
5. Known issues
6. Future direction
7. Comments/suggestions/credits


1. Introduction

This extension is designed to provide access to the Ingres Enterprise Relational Database Management System. Native or direct access is provided for Ingres II 2.0, Ingres II 2.5, Advantage Ingres 2.6 and Ingres r3. To access older versions, a supported client environment can be used with Ingres/NET.

In 2005, the Ingres extension was moved to the PHP extension community library (PECL) to resolve a build conflict with Windows and UNIX/Linux platforms. One advantage of this move is it allows the extension to be developed with its own release cycle. This permits new functionality to be released when possible instead of waiting for the next official PHP release. Rather than being available via the main PHP tarball/zip archive (http://www.php.net/downloads), an additional download is required.



2. Platform support

Ingres Releases

This extension has been written to support the following versions of Ingres:

PHP Releases

This extension has been written against PHP 5.1. Prior versions of PHP, i.e. 4.0.x - 5.0, contain an earlier version of the Ingres extension. Building the extension with earlier versions requires the deletion of the ingres_ii directory under ext.

Operating System Compatibility

The extension should work against any platform where the above Ingres releases are supported. In practice the extension has been developed on Windows XP using Visual Studio .Net 2003 (VC7) and SuSE 9.3/Fedora Core 3 using GCC 3.3.x. There has been limited testing on Solaris 9 Sparc. If you find the extension does not work, please contact grantc@php.net with the following information:



3. Function support

The extension provides the following functionality:

FunctionDescription
ingres_autocommitSwitch autocommit on or off
ingres_closeClose an Ingres database connection
ingres_commitCommit a transaction
ingres_connectOpen a connection to an Ingres database
ingres_cursorGet the name of the cursor in use
ingres_errorGet the error text
ingres_errnoGet the error code
ingres_errsqlstateGet the SQLState
ingres_fetch_arrayFetch a row of result into an array
ingres_fetch_objectFetch a row of result into an object
ingres_fetch_rowFetch a row of result into an enumerated array
ingres_field_lengthGet the length of a field
ingres_field_nameGet the name of a field in a query result
ingres_field_nullableTest if a field is nullable
ingres_field_precisionGet the precision of a field
ingres_field_scaleGet the scale of a field
ingres_field_typeGet the type of a field in a query result
ingres_num_fieldsGet the number of fields returned by the last query
ingres_num_rowsGet the number of rows affected or returned by the last query
ingres_pconnectOpen a persistent connection to an Ingres database
ingres_querySend a SQL query to Ingres
ingres_rollbackRollback a transaction

Project home page

The latest tar ball for this extension can be downloaded from http://pecl.php.net/project/ingres. At the moment only source code is available for download via this page. Development snapshot builds of the PECL extension for Windows can be downloaded from http://snaps.php.net. Binary releases for certain operating systems will be provided in due course.



4. Installing the extension

Windows Installation

The latest binaries for the Ingres extension can be downloaded from
http://snaps.php.net. Direct links are provided below for different PHP releases:

To activate the extension copy php_ingres.dll into the extension_dir configured in php.ini. Then add the following line to php.ini:

	extension=php_ingres.dll

UNIX/Linux Installation

The installation of the extension on UNIX/Linux will require a C complilation environment.

The latest source code can be downloaded manually from http://pecl.php.net/get/ingres. Or by using PEAR:

	pear download ingres

Once you have the source archive run through the following steps to build and install:
  1. Extract the archive, adapt the version number accordingly:
    tar -zxvf ingres-1.0.tgz
  2. Enter the newly created directory:
    cd ingres-1.0
  3. Generate the configuration file for the extension:
    phpize
  4. Generate the Makefile needed to build the extension:
    ./configure
  5. Build the extension:
    make
  6. Install the extension, N.B. this may require root access :
    make install


5. Known issues

Linux



6. Future direction

Since the code has been relatively stable for a number of years, all current development efforts have tried to avoid, where possible, changing syntax of any existing function. The TODO file covers the items that are on the list to be implemented.

There are, however, some things that would be nice to have but might prove difficult to implement without breaking backwards compatibility, either with versions of Ingres or with existing Ingres based PHP code.

The extension uses IIapi_setConnectParm() to affect the behaviour of the extension. Such that it is possible to override the current date format, money format amongst other things. Since PHP is weakly typed (there are only 4 types that map to Ingres types), conversion from Ingres types to PHP types needs to take place when fetching data. The OpenAPI function IIapi_convertData() is used to do this. However IIapi_convertData() is unable to observe certain environmental parameters since setting parameter values via IIapi_setConnectParm() affects all connections. Ingres II 2.5 overcomes this with the addition of an environment handle and a new function to convert between different data types, IIapi_formatData(). To properly support data conversion Ingres 2.0 can no longer be used, on the client.

The current extension maintains a single statement handle. Whenever a query is executed via ingres_query() or ingres_prepare(), any existing statement is terminated/closed. For multiple resultsets to work, the ingres_fetch_*() statements will need to be able to accept a resource that represents an Ingres resultset. Such that:

  ingres_fetch_row( [resource link] ) 

would have to change to:

  ingres_fetch_row( resource result )

Note '[]' means anything contained within is optional. Apart from passing a result resource instead of a link resource, the main difference is the parameter passed would be a mandatory parameter rather than optional as it is at the moment. This is more in keeping with how other PHP database interfaces work. Link resource parameters that are currently optional would become mandatory. Implementing this would make the extension incompatible with existing scripts that use Ingres.

It is possible for the code to be branched such that any future versions that break backwards compatibility are clearly marked as doing so. This will be done according to demand.



7. Comments/suggestions/credits

The architecture for the Ingres extension is based on code written by David Henot (henot@php.net) from 2000-2004.  Since February 2005, Grant Croker, (grantc@php.net), took over the maintenance and development of the extension.

If you have any comments, features or if you wish to assist in some way with coding, testing or documentation please contact grantc@php.net.