Ingres Community Forums Login Register Ingres.com  

Ingres Community Wiki

Navigation
Learn About
Developing With
Ingres Talk
Information
Toolbox

PHP Driver

From Ingres Community Wiki

Jump to: navigation, search

Contents

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.


Platform support

Ingres Releases

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

  • Ingres II 2.0/OpenIngres 2.0
  • Ingres II 2.5
  • Advantage Ingres 2.6
  • Ingres r3
  • Ingres 2006
  • Ingres 2006 r2
  • Ingres 2006 r3

PHP Releases

This extension has been developed against PHP 5.2.x. Prior versions of PHP, i.e. 4.0.x - 5.0.x, 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 10.3 using GCC 4.x. There has been limited testing on Solaris 10 Sparc. If you find the extension does not work, please log a bug via the project home page with the following information:

  • operating system and patches/service pack installed
  • compiler + version used to build the extension
  • version of PHP being used
  • version of Ingres being used
  • if you managed to get the extension built, the value of the constants INGRES_EXT_VERSION and INGRES_API_VERSION:
<?php
	echo INGRES_EXT_VERSION . " " . INGRES_API_VERSION . "<br />\n";
?> 

Function support

The extension provides the following functionality:

Function Description
ingres_autocommit Switch autocommit on or off
ingres_close Close an Ingres database connection
ingres_commit Commit a transaction
ingres_connect Open a connection to an Ingres database
ingres_cursor Get the name of the cursor in use
ingres_error Get the error text
ingres_errno Get the error code
ingres_errsqlstate Get the SQLState
ingres_execute Execute a cursor prepared by ingres_prepare
ingres_fetch_array Fetch a row of result into an array
ingres_fetch_object Fetch a row of result into an object
ingres_fetch_proc_return Get the return value from a procedure call
ingres_fetch_row Fetch a row of result into an enumerated array
ingres_field_length Get the length of a field
ingres_field_name Get the name of a field in a query result
ingres_field_nullable Test if a field is nullable
ingres_field_precision Get the precision of a field
ingres_field_scale Get the scale of a field
ingres_field_type Get the type of a field in a query result
ingres_num_fields Get the number of fields returned by the last query
ingres_num_rows Get the number of rows affected or returned by the last query
ingres_pconnect Open a persistent connection to an Ingres database
ingres_prepare Prepares a query for execution byingres_execute
ingres_query Send a SQL query to Ingres
ingres_set_environment Set one or more Ingres environment variables
ingres_rollback Rollback 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://esd.ingres.com/.

Installing the extension

Windows Installation

The latest binaries for the Ingres extension can be downloaded from http://esd.ingres.com/product/drivers/PHP/Windows_32-Bit/PHP_Driver/

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, note that $II_SYSTEM needs to be defined beforehand:

  1. Extract the archive, adapt the version number accordingly: tar -zxvf ingres-2.0.0.tgz
  2. Enter the newly created directory: cd ingres-2.0.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

Ingres with the Apache web server on UNIX/Linux

This extension, like other Ingres applications, requires knowledge of a local Ingres installation. Providing Apache with this information can be done two ways both of which require mod_env. The following assumes Ingres was installed to /opt/Ingres/II:

  • Using PassEnv:
    • In the script that starts Apache add the following lines:
II_SYSTEM=/opt/Ingres/II
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$II_SYSTEM/ingres/lib
export II_SYSTEM LD_LIBRARY_PATH
    • Add the following lines to the apache configuration script httpd.conf (or equivalent):
PassEnv II_SYSTEM LD_LIBRARY_PATH
  • Using SetEnv:
    • Add the following lines to the Apache configuration script httpd.conf (or equivalent):
SetEnv II_SYSTEM /opt/Ingres/II
SetEnv LD_LIBRARY_PATH /opt/Ingres/II/ingres/lib

Configuration Options

The following output represents the configuration options with their respective defaults. Either include the text in the system wide php.ini or save as a separate file and place in the directory PHP uses to pickup additional configuration files. *Note* If the extension has been configured with the "--enable-ingres2" flag, all ingres.xxxx options become ingres2.xxxx.

[ingres]

; Loading the extension on UNIX/Linux - remove the ";" to use this entry.
;extension=ingres.so
; Loading the extension on Windows - remove the ";" to use this entry.
;extension=php_ingres.dll

; Ingres configuration settings

; Allow or prevent persistent links.
ingres.allow_persistent = On

; Maximum number of persistent links.  -1 means no limit.
ingres.max_persistent = -1

; Maximum number of links, including persistent connections.  -1 means no limit.
ingres.max_links = -1

; Default database (format: [node_id::]dbname[/srv_class]).
ingres.default_database =

; Default user.
ingres.default_user =

; Default password.
ingres.default_password =

; Suppress DB warnings
ingres.report_db_warnings = Off

; The amount of memory to use when reading BLOB data
ingres.blob_segment_length = 4096

; Print E_NOTICE messages during ingres_connect/ingres_pconnect calls
ingres.trace_connect = Off

; Time in ms the OpenAPI IIapi_initialize function will wait before failing
; -1 means do not wait.
ingres.timeout = -1

; By default the array returned by ingres_fetch_array() indexes from 1.
; To make the Ingres extension compatible with other database extensions
; set this to 0.
ingres.array_index_start = 1

; Convert all UTF8 strings to UTF-16
ingres.utf8 = 1

; Reuse the existing connection where the database and username match
; The default behaviour has always been to reuse
ingres.reuse_connection = 1

Example Code

For example PHP code that makes use of the Ingres extension see PHP Driver Examples

Known issues

There are no known issues at this time.

Personal tools
© 2009 Ingres Corporation. All Rights Reserved