Login Register Actian.com  

Actian Community Wiki

Navigation
Learn About
Developing With
Ingres Talk
Information
Toolbox

PHP/Projects/BOOLEAN

From Ingres Community Wiki

Jump to: navigation, search

Contents

Introduction

This page contains the implementation details for adding support for the Ingres BOOLEAN type to the PHP driver.

PHP Language Support

The PHP interpreter has a native boolean type which maps to the C short int values 0 and 1.

<?php
$foo = True; // assign the value TRUE to $foo
?>

Current driver support

The driver currently sends boolean values as an IIAPI_INT_TYPE 0 or 1 to the server. There is no support for fetching an Ingres BOOLEAN value.

Proposed driver support

  • Fetching
    • IIAPI_BOOL_TYPE
      • Add IIAPI_BOOL_TYPE to the case statement that matches Ingres to PHP types
      • Add to return_value using add_index_bool() and add_assoc_bool()
        • IIAPI_BOOL_TYPE == PHP BOOLEAN type
    • IIAPI_INT_TYPE
      • Used to store PHP BOOLEAN values up until now
      • No way to know if the fetched value is a intended for a PHP LONG or BOOLEAN value
      • Could have a config option that treats an INT1 (IIAPI_INT_TYPE/dv_length=1) whose value is 0 or 1 as a PHP BOOLEAN
        • No one has raised Ingres -> PHP Boolean conversion as an issue until now so I'm not sure it's a problem
  • Putting
    • DESCRIBE INPUT allows for direct mapping from PHP into Ingres such that:
      • If IIAPI_VERSION_7 then PHP sent as IIAPI_BOOL_TYPE
      • Else Send as IIAPI_INT_TYPE
    • Non-DESCRIBE INPUT
      • Same as DESCRIBE INPUT except it's not known (//currently//) what happens if you send an IIAPI_BOOL_TYPE value into a column of type IIAPI_INT_TYPE

Backwards Compatibility

BOOLEAN support will only be available when the driver has been build against an Ingres 10.0 or newer ( >= IIAPI_VERSION_7). When the driver, built against Ingres 10.0 or newer is connected to an earlier release of Ingres, whose IIAPI_LEVEL is less than 6 PHP BOOLEAN values will get sent as a PHP LONG, as happens at present.

Function changes

The following functions will need to be updated

  • php_ii_field_info() - Add IIAPI_BOOL_TYPE to II_FIELD_INFO_TYPE
  • php_ii_fetch() - Coerce IIAPI_BOOL_TYPE into a PHP BOOLEAN
  • php_ii_bind_params()
    • If ingres.describe = On (use DESCRIBE INPUT)
      • match PHP BOOL to IIAPI_BOOL_TYPE assuming the server supports it
    • else
      • Map type code 'a' (for assertion !?!) to IIAPI_BOOL_TYPE
      • Send untyped value (where ingres_query() is not provided with any types) as either IIAPI_BOOL_TYPE or IIAPI_INT_TYPE depending on whether the server supports it or not
Personal tools
© 2011 Actian Corporation. All Rights Reserved