]> granicus.if.org Git - php/commitdiff
@- Added Input Descriptor Binding to Informix driver. (Corne')
authorCorne' Cornelius <nobbie@php.net>
Thu, 20 Feb 2003 12:09:21 +0000 (12:09 +0000)
committerCorne' Cornelius <nobbie@php.net>
Thu, 20 Feb 2003 12:09:21 +0000 (12:09 +0000)
- Added Input Descriptor Binding
  . (php_intifx_init_blob) Added
  . (php_intifx_init_blob_inmem) Added
  . (php_intifx_init_blob_infile) Added
  . (php_intifx_release_blob) Added
  . (php_intifx2_free_blob) Removed
  . (php_intifx_create_tmpfile) Removed bid parameter
  . (php_intifx_alloc_ibind) Added
  . (php_intifx_preparse) Added
  . (php_intifx_count_descriptors) Added
  . (ifx_free_blob) Added as le_idresult resource destructor
  . (php_intifx_create_blob) Changed: added call to php_intifx_init_blob() and
                             removed blob initilisation in function
  . (php_intifx_copy_blob) Changed: added call to php_intifx_init_blob() and
                           removed blob initilisation in function
  . (php_intifx_update_blob) Changed mempy() to use lob_bufsize instead of loc_size
                             Changed filename to be memcpy() instead of creating
                             new file
  . (PHP ifx_query) Changed: added input descriptor binding
  . (PHP ifx_prepare) Changed: added input descriptor binding
  . (PHP ifx_do) Chagned: added input descriptor binding
  . (PHP ifx_fetch_row) Changed the way blobs are accessed/init'd from
                        Ifx_Result->res_id[]

ext/informix/ifx.ec
ext/informix/php_informix_includes.h

index 82a0d5b27a4ee8664eb639f8ec7acde1bef8f6fa..f43c25b5b439174ac501a4946c549940653f97b2 100644 (file)
 static void php_ifx_set_default_link(int id TSRMLS_DC);
 static long php_intifx_getType(long id, HashTable *list TSRMLS_DC);
 static long php_intifx_create_blob(long type, long mode, char* param, long len, HashTable *list TSRMLS_DC);
+static long php_intifx_init_blob(loc_t *blob, long mode, long new TSRMLS_DC);
+static long php_intifx_init_blob_inmem(loc_t *blob, long new TSRMLS_DC);
+static long php_intifx_init_blob_infile(loc_t *blob, long new TSRMLS_DC);
+static void php_intifx_release_blob(loc_t *blob TSRMLS_DC);
 static long php_intifx_free_blob(long id, HashTable *list TSRMLS_DC);
-static long php_intifx2_free_blob(long id, HashTable *list TSRMLS_DC);
 static long php_intifx_get_blob(long bid, HashTable *list, char** content TSRMLS_DC);
 static long php_intifx_update_blob(long bid, char* param, long len, HashTable *list TSRMLS_DC);
 static loc_t *php_intifx_get_blobloc(long bid, HashTable *list TSRMLS_DC);
-static char* php_intifx_create_tmpfile(long bid TSRMLS_DC);
+static char* php_intifx_create_tmpfile(TSRMLS_DC);
 static long php_intifx_copy_blob(long bid, HashTable *list TSRMLS_DC);
+static long php_intifx_alloc_ibind(IFX_RES *Ifx_Result, int items TSRMLS_DC);
+static long php_intifx_preparse(char *statement TSRMLS_DC);
+static long php_intifx_count_descriptors(char *p_statemid TSRMLS_DC);
 static char* php_intifx_null(TSRMLS_D);
 static long php_intifx_create_char(char* param, long len, HashTable *list TSRMLS_DC);
 static long php_intifx_free_char(long id, HashTable *list TSRMLS_DC);
@@ -116,7 +122,7 @@ typedef char IFX[128];
         {                                   \
             if (ifx_check() < 0) {          \
                 IFXG(sv_sqlcode) = SQLCODE; \
-                php_error(E_WARNING, "%s(): Set connection %s fails (%s)", get_active_function_name(TSRMLS_C), ifx, ifx_error(ifx)); \
+                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Set connection %s fails (%s)", ifx, ifx_error(ifx)); \
                 RETURN_FALSE;               \
             }                               \
         }    
@@ -312,6 +318,16 @@ static void ifx_free_result(zend_rsrc_list_entry *rsrc TSRMLS_DC)
        efree(Ifx_Result);
 }
 
+static void ifx_free_blob(zend_rsrc_list_entry *rsrc TSRMLS_DC)
+{
+       IFX_IDRES *Ifx_blob = (IFX_IDRES *)rsrc->ptr;
+
+       
+       php_intifx_release_blob(&Ifx_blob->BLOB.blob_data TSRMLS_C);
+
+       efree(Ifx_blob); 
+}
+
 PHP_INI_BEGIN()
        STD_PHP_INI_BOOLEAN("ifx.allow_persistent", "1",  PHP_INI_SYSTEM, OnUpdateInt,    allow_persistent, zend_ifx_globals, ifx_globals)
        STD_PHP_INI_ENTRY_EX("ifx.max_persistent",  "-1", PHP_INI_SYSTEM, OnUpdateInt,    max_persistent,   zend_ifx_globals, ifx_globals, display_link_numbers)
@@ -342,7 +358,7 @@ PHP_MINIT_FUNCTION(ifx)
        REGISTER_INI_ENTRIES();
 
        le_result   = zend_register_list_destructors_ex(ifx_free_result,NULL, "informix result",    module_number);
-       le_idresult = zend_register_list_destructors_ex(NULL, NULL, "informix id result", module_number);
+       le_idresult = zend_register_list_destructors_ex(ifx_free_blob, NULL, "informix id result", module_number);
        le_link     = zend_register_list_destructors_ex(_close_ifx_link,NULL, "informix link",      module_number);
        le_plink    = zend_register_list_destructors_ex(NULL,_close_ifx_plink,"informix persistent link", module_number);
        ifx_module_entry.type = type;
@@ -421,7 +437,7 @@ EXEC SQL END DECLARE SECTION;
 
        if (PG(sql_safe_mode)) {
                if (ZEND_NUM_ARGS()>0) {
-                       php_error(E_NOTICE, "%s(): SQL safe mode in effect - ignoring host/user/password information", get_active_function_name(TSRMLS_C));
+                       php_error_docref(NULL TSRMLS_CC, E_NOTICE, "SQL safe mode in effect - ignoring host/user/password information");
                }
                host = passwd = NULL;
                user = php_get_current_user();
@@ -468,12 +484,12 @@ EXEC SQL END DECLARE SECTION;
                        list_entry new_le;
 
                        if (IFXG(max_links)!=-1 && IFXG(num_links) >= IFXG(max_links)) {
-                               php_error(E_WARNING, "%s(): Too many open links (%d)", get_active_function_name(TSRMLS_C), IFXG(num_links));
+                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Too many open links (%d)", IFXG(num_links));
                                efree(hashed_details);
                                RETURN_FALSE;
                        }
                        if (IFXG(max_persistent)!=-1 && IFXG(num_persistent) >= IFXG(max_persistent)) {
-                               php_error(E_WARNING, "%s(): Too many open persistent links (%d)", get_active_function_name(TSRMLS_C), IFXG(num_persistent));
+                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Too many open persistent links (%d)", IFXG(num_persistent));
                                efree(hashed_details);
                                RETURN_FALSE;
                        }
@@ -487,7 +503,7 @@ EXEC SQL END DECLARE SECTION;
        
                        if (ifx_check() == IFX_ERROR) {
                                IFXG(sv_sqlcode) = SQLCODE;
-                               php_error(E_WARNING, "%s(): %s", get_active_function_name(TSRMLS_C), ifx_error(ifx));
+                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", ifx_error(ifx));
                                free(ifx);
                                efree(hashed_details);
                                RETURN_FALSE;
@@ -517,7 +533,7 @@ EXEC SQL END DECLARE SECTION;
                                
                                if (ifx_check() == IFX_ERROR) {
                                        IFXG(sv_sqlcode) = SQLCODE;
-                                       php_error(E_WARNING, "%s(): Link to server lost, unable to reconnect (%s)", get_active_function_name(TSRMLS_C), ifx_error(ifx));
+                                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Link to server lost, unable to reconnect (%s)", ifx_error(ifx));
                                        zend_hash_del(&EG(persistent_list), hashed_details, hashed_details_length+1);
                                        efree(hashed_details);
                                        RETURN_FALSE;
@@ -555,7 +571,7 @@ EXEC SQL END DECLARE SECTION;
 
                                        if (ifx_check() == IFX_ERROR) {
                                                IFXG(sv_sqlcode) = SQLCODE;
-                                               php_error(E_WARNING, "%s(): Unable to connect (%s)", get_active_function_name(TSRMLS_C), ifx_error(ifx));
+                                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to connect (%s)", ifx_error(ifx));
                                                zend_hash_del(&EG(regular_list), hashed_details, hashed_details_length+1);
                                                efree(hashed_details);
                                                RETURN_FALSE;
@@ -572,7 +588,7 @@ EXEC SQL END DECLARE SECTION;
                        }
                }
                if (IFXG(max_links) != -1 && IFXG(num_links) >= IFXG(max_links)) {
-                       php_error(E_WARNING, "%s(): Too many open links (%d)", get_active_function_name(TSRMLS_C), IFXG(num_links));
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Too many open links (%d)", IFXG(num_links));
                        efree(hashed_details);
                        RETURN_FALSE;
                }
@@ -585,7 +601,7 @@ EXEC SQL END DECLARE SECTION;
 
                if (ifx_check() == IFX_ERROR) {
                        IFXG(sv_sqlcode) = SQLCODE;
-                       php_error(E_WARNING,"%s(): %s", get_active_function_name(TSRMLS_C), ifx_error(ifx));
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", ifx_error(ifx));
                        efree(hashed_details);
                        efree(ifx);
                        RETURN_FALSE;
@@ -710,6 +726,7 @@ EXEC SQL BEGIN DECLARE SECTION;
        char cursorid[32];        /* query cursor id   */
        char statemid[32];        /* statement id      */
        char descrpid[32];        /* descriptor id     */
+       char i_descrpid[32];      /* input descriptor binding */
        char *statement;          /* query text        */
        int  fieldcount;          /* field count       */
        int  i;                   /* field index       */
@@ -720,12 +737,12 @@ EXEC SQL BEGIN DECLARE SECTION;
        char *char_tmp;
        long len;
        int indicator;
+       int desc_count;
 $ifdef HAVE_IFX_IUS;
        fixed binary 'blob' ifx_lo_t *slocator;
 $endif;
 EXEC SQL END DECLARE SECTION;
 
-       char *blobfilename;
        int  locind;
        int  ctype;
        int  affected_rows;
@@ -735,6 +752,7 @@ EXEC SQL END DECLARE SECTION;
        int  cursoryproc;
        int  argc=ZEND_NUM_ARGS();
        long ifx_type;
+       int num_params;
 
        if(argc < 2 || zend_get_parameters_ex(argc, &query, &ifx_link, &dummy, &dummy)==FAILURE) {
                WRONG_PARAM_COUNT;
@@ -752,6 +770,7 @@ EXEC SQL END DECLARE SECTION;
        sprintf(statemid, "statem%x", IFXG(cursorid)); 
        sprintf(cursorid, "cursor%x", IFXG(cursorid)); 
        sprintf(descrpid, "descrp%x", IFXG(cursorid)); 
+       sprintf(i_descrpid, "i_descrp%x", IFXG(cursorid));
 
        EXEC SQL set connection :ifx;
        PHP_IFX_CHECK_CONNECTION(ifx);
@@ -759,48 +778,67 @@ EXEC SQL END DECLARE SECTION;
        EXEC SQL PREPARE :statemid FROM :statement;
        if (ifx_check() < 0) {
                IFXG(sv_sqlcode) = SQLCODE;
-               php_error(E_WARNING, "%s(): Prepare fails (%s)", get_active_function_name(TSRMLS_C), ifx_error(ifx));
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Prepare fails (%s)", ifx_error(ifx));
                RETURN_FALSE;
        }
 
        affected_rows = sqlca.sqlerrd[0];       /* save estimated affected rows */
        for (e = 0; e < 6; e++) sqlerrd[e] = sqlca.sqlerrd[e];
    
-       EXEC SQL ALLOCATE DESCRIPTOR :descrpid WITH MAX 384;
-       if (ifx_check() < 0) {
+       num_params = php_intifx_preparse(statement);
+
+       Ifx_Result = (IFX_RES *) emalloc(sizeof(IFX_RES));
+       if (Ifx_Result == NULL) {
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Out of memory allocating IFX_RES");
+               EXEC SQL free :statemid;
+               RETURN_FALSE;
+       }
+
+       /* initialize result data structure */
+       Ifx_Result->rowid = 0;
+       strcpy(Ifx_Result->connecid, ifx);
+       strcpy(Ifx_Result->cursorid, cursorid);
+       strcpy(Ifx_Result->descrpid, descrpid);
+       strcpy(Ifx_Result->i_descrpid, i_descrpid);
+       strcpy(Ifx_Result->statemid, statemid);
+       Ifx_Result->numcols = 0;
+       Ifx_Result->numicols = 0;
+
+       for (i = 0; i < MAX_RESID; ++i) {
+               Ifx_Result->res_id[i] = -1;
+       }
+
+       if (!php_intifx_alloc_ibind(Ifx_Result, num_params))   {
                IFXG(sv_sqlcode) = SQLCODE;
-               php_error(E_WARNING, "%s(): Allocate desciptor <%s> fails (%s)", get_active_function_name(TSRMLS_C), descrpid, ifx_error(ifx));
                EXEC SQL free :statemid;
+               efree(Ifx_Result);
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Allocate i_desciptor <%s> fails (%s)", i_descrpid, ifx_error(ifx));
                RETURN_FALSE;
        }
 
-       EXEC SQL DESCRIBE :statemid USING SQL DESCRIPTOR :descrpid;
+
+       desc_count = php_intifx_count_descriptors(statemid);
+       if (desc_count == 0)
+               desc_count = 1;
+
+       EXEC SQL ALLOCATE DESCRIPTOR :descrpid WITH MAX :desc_count;
        if (ifx_check() < 0) {
                IFXG(sv_sqlcode) = SQLCODE;
-               php_error(E_WARNING, "%s(): Describe fails (%s)", get_active_function_name(TSRMLS_C), ifx_error(ifx));
-               EXEC SQL DEALLOCATE DESCRIPTOR :descrpid;
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Allocate desciptor <%s> fails (%s)", descrpid, ifx_error(ifx));
                EXEC SQL free :statemid;
                RETURN_FALSE;
        }
 
-       query_type = sqlca.sqlcode;
-
-       Ifx_Result = (IFX_RES *) emalloc(sizeof(IFX_RES));
-       if (Ifx_Result == NULL) { 
-               php_error(E_WARNING, "%s(): Out of memory allocating IFX_RES", get_active_function_name(TSRMLS_C));
+       EXEC SQL DESCRIBE :statemid USING SQL DESCRIPTOR :descrpid;
+       if (ifx_check() < 0) {
+               IFXG(sv_sqlcode) = SQLCODE;
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Describe fails (%s)", ifx_error(ifx));
                EXEC SQL DEALLOCATE DESCRIPTOR :descrpid;
                EXEC SQL free :statemid;
                RETURN_FALSE;
        }
 
-       /* initialize result data structure */
-
-       Ifx_Result->rowid = 0;
-       strcpy(Ifx_Result->connecid, ifx); 
-       strcpy(Ifx_Result->descrpid, descrpid);
-       for (i = 0; i < MAX_RESID; ++i) {
-               Ifx_Result->res_id[i] = -1;
-       }
+       query_type = sqlca.sqlcode;
 
        cursoryproc = 0;
        if (query_type == SQ_EXECPROC) {
@@ -820,40 +858,45 @@ EXEC SQL END DECLARE SECTION;
                */
                zval **pblobidarr, **tmp;
 
+               /* We don't need this descriptor anymore, NONSELECT-STATEMENT */
+               EXEC SQL DEALLOCATE DESCRIPTOR :descrpid;
+
                Ifx_Result->iscursory = 0;
-               strcpy(Ifx_Result->cursorid, "");
-               strcpy(Ifx_Result->descrpid, descrpid);
-               strcpy(Ifx_Result->statemid, statemid);
 
                if(argc > 3) {
                        WRONG_PARAM_COUNT;
                }
 
                if(argc == 3) {
+
+                       if (Ifx_Result->numicols <= 0)   {
+                               IFXG(sv_sqlcode) = SQLCODE;
+                               EXEC SQL free :statemid;
+                               efree(Ifx_Result);
+                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "No placeholders (?) in Statement, but blob array param supplied");
+                               RETURN_FALSE;
+                       }
+
                        if (zend_get_parameters_ex(3, &dummy, &dummy, &pblobidarr) == FAILURE) {
                                IFXG(sv_sqlcode) = SQLCODE;
-                               EXEC SQL DEALLOCATE DESCRIPTOR :descrpid;
+                               EXEC SQL DEALLOCATE DESCRIPTOR :i_descrpid;
                                EXEC SQL free :statemid;
                                efree(Ifx_Result);
-                               php_error(E_WARNING, "%s(): Can't get blob array param", get_active_function_name(TSRMLS_C));
+                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can't get blob array param");
                                RETURN_FALSE;
                        }
                        if (Z_TYPE_PP(pblobidarr) != IS_ARRAY) {
                                IFXG(sv_sqlcode) = SQLCODE;
-                               EXEC SQL DEALLOCATE DESCRIPTOR :descrpid;
+                               EXEC SQL DEALLOCATE DESCRIPTOR :i_descrpid;
                                EXEC SQL free :statemid;
                                efree(Ifx_Result);
-                               php_error(E_WARNING, "%s(): Blob-parameter is not an array", get_active_function_name(TSRMLS_C));
+                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Blob-parameter is not an array");
                                RETURN_FALSE;
                        }
 
                        zend_hash_internal_pointer_reset((*pblobidarr)->value.ht);
-                       i=1;
-                       while (zend_hash_get_current_data((*pblobidarr)->value.ht, (void **) &tmp) == SUCCESS) {
+                       for (i = 1; i <= Ifx_Result->numicols && (zend_hash_get_current_data((*pblobidarr)->value.ht, (void **) &tmp) == SUCCESS); ++i) {
                                convert_to_long(*tmp);
-                               if ((query_type == SQ_UPDATE) || (query_type == SQ_UPDALL)) {
-                                       EXEC SQL SET DESCRIPTOR :descrpid COUNT = :i;
-                               }
 
                                ifx_type=php_intifx_getType((int)(*tmp)->value.lval,&EG(regular_list) TSRMLS_CC);
                                switch(ifx_type) {
@@ -862,16 +905,16 @@ EXEC SQL END DECLARE SECTION;
                                                locator=php_intifx_get_blobloc((int)((*tmp)->value.lval),&EG(regular_list) TSRMLS_CC);
                                                if(locator==NULL) {
                                                        IFXG(sv_sqlcode) = SQLCODE;
-                                                       EXEC SQL DEALLOCATE DESCRIPTOR :descrpid;
+                                                       EXEC SQL DEALLOCATE DESCRIPTOR :i_descrpid;
                                                        EXEC SQL free :statemid;
                                                        efree(Ifx_Result);
-                                                       php_error(E_WARNING,"%s(): %d is not an Informix blob-result index", get_active_function_name(TSRMLS_C), (int)((*tmp)->value.lval));
+                                                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "%d is not an Informix blob-result index", (int)((*tmp)->value.lval));
                                                        RETURN_FALSE;
                                                }
                                                if(locator->loc_loctype==LOCFNAME) {
                                                        locator->loc_oflags=LOC_RONLY;
                                                }
-                                               EXEC SQL SET DESCRIPTOR :descrpid VALUE :i DATA= :*locator, TYPE= :loc_t_type;
+                                               EXEC SQL SET DESCRIPTOR :i_descrpid VALUE :i DATA = :*locator, TYPE = :loc_t_type;
                                                break;
 
                                        case TYPE_CHAR:
@@ -889,21 +932,41 @@ EXEC SQL END DECLARE SECTION;
                                                        TYPE= :sqlchar_type;
                                                break;
                                }
-                               i++;
+
+                               if (ifx_check() < 0)   {
+                                       IFXG(sv_sqlcode) = SQLCODE;
+                                       EXEC SQL DEALLOCATE DESCRIPTOR :i_descrpid;
+                                       EXEC SQL free :statemid;
+                                       efree(Ifx_Result);
+                                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Execute immediate fails : %s", ifx_error(ifx));
+                                       RETURN_FALSE;
+                               }
+
                                zend_hash_move_forward((*pblobidarr)->value.ht);
                        }
                        Ifx_Result->paramquery=1;  
-                       EXEC SQL EXECUTE :statemid USING SQL DESCRIPTOR :descrpid;
+
+                       if (i - 1 != Ifx_Result->numicols)   {
+                               EXEC SQL DEALLOCATE DESCRIPTOR :i_descrpid;
+                               EXEC SQL free :statemid;
+                               efree(Ifx_Result);
+                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Execute immediate fails : number of created blobs doesn't match placeholders (?)");
+                               RETURN_FALSE;
+                       }
+
+                       EXEC SQL EXECUTE :statemid USING SQL DESCRIPTOR :i_descrpid;
                } else {
                        EXEC SQL EXECUTE :statemid;
                }
 
                if (ifx_check() < 0) {
                        IFXG(sv_sqlcode) = SQLCODE;
-                       EXEC SQL DEALLOCATE DESCRIPTOR :descrpid;
+                       if (Ifx_Result->numicols > 0)   {
+                               EXEC SQL DEALLOCATE DESCRIPTOR :i_descrpid;
+                       }
                        EXEC SQL free :statemid;
                        efree(Ifx_Result);
-                       php_error(E_WARNING, "%s(): Execute immediate fails : %s (%s)", get_active_function_name(TSRMLS_C), statement, ifx_error(ifx));
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Execute immediate fails : %s", ifx_error(ifx));
                        RETURN_FALSE;
                }
                Ifx_Result->affected_rows = sqlca.sqlerrd[2]; /* really affected */
@@ -940,7 +1003,7 @@ EXEC SQL END DECLARE SECTION;
                        EXEC SQL DEALLOCATE DESCRIPTOR :descrpid;
                        EXEC SQL free :statemid;
                        efree(Ifx_Result);
-                       php_error(E_WARNING, "%s(): Can not get descriptor %s (%s)", get_active_function_name(TSRMLS_C), descrpid, ifx_error(ifx));
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can not get descriptor %s (%s)", descrpid, ifx_error(ifx));
                        RETURN_FALSE;
                }
 
@@ -954,6 +1017,10 @@ EXEC SQL END DECLARE SECTION;
                        Ifx_Result->ishold = 1;
                }
 
+               /*
+                * ifx_do() part
+                */
+
                if (Ifx_Result->isscroll) {
                        if (Ifx_Result->ishold) {
                                EXEC SQL DECLARE :cursorid SCROLL CURSOR WITH HOLD FOR :statemid;
@@ -973,7 +1040,7 @@ EXEC SQL END DECLARE SECTION;
                        EXEC SQL DEALLOCATE DESCRIPTOR :descrpid;
                        EXEC SQL free :statemid;
                        efree(Ifx_Result);
-                       php_error(E_WARNING, "%s(): Declare cursor fails (%s)", get_active_function_name(TSRMLS_C), ifx_error(ifx));
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Declare cursor fails (%s)", ifx_error(ifx));
                        RETURN_FALSE;
                }
 
@@ -984,12 +1051,9 @@ EXEC SQL END DECLARE SECTION;
                        EXEC SQL free :statemid;
                        EXEC SQL free :cursorid;
                        efree(Ifx_Result);
-                       php_error(E_WARNING, "%s(): Open cursor fails (%s)", get_active_function_name(TSRMLS_C), ifx_error(ifx));
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Open cursor fails (%s)", ifx_error(ifx));
                        RETURN_FALSE;
                }
-               strcpy(Ifx_Result->cursorid, cursorid);
-               strcpy(Ifx_Result->descrpid, descrpid);
-               strcpy(Ifx_Result->statemid, statemid);
 
                /* check for text/blob columns */
                locind = 0;
@@ -1002,22 +1066,28 @@ $endif;
                        ) {
                                int bid = 0;
                                if(fieldtype==SQLTEXT) {
-                                       bid=php_intifx_create_blob(TYPE_BLTEXT,BLMODE_INMEM,"",-1,&EG(regular_list) TSRMLS_CC);
-                                       locator=php_intifx_get_blobloc(bid,&EG(regular_list) TSRMLS_CC);
+                                       if(IFXG(blobinfile)==0) {
+                                               bid=php_intifx_create_blob(TYPE_BLTEXT,BLMODE_INMEM,"",-1,&EG(regular_list) TSRMLS_CC);
+                                               locator=php_intifx_get_blobloc(bid,&EG(regular_list) TSRMLS_CC);
+                                       } else {
+                                               bid=php_intifx_create_blob(TYPE_BLTEXT,BLMODE_INFILE, "",-1,&EG(regular_list) TSRMLS_CC);
+                                               locator=php_intifx_get_blobloc(bid,&EG(regular_list) TSRMLS_CC);
+                                       }
+
                                        EXEC SQL SET DESCRIPTOR :descrpid VALUE :i DATA = :*locator;
                                }
-                               if(fieldtype==SQLBYTES) {
+                               else if(fieldtype==SQLBYTES) {
                                        if(IFXG(blobinfile)==0) {
                                                bid=php_intifx_create_blob(TYPE_BLBYTE,BLMODE_INMEM,"",-1,&EG(regular_list) TSRMLS_CC);
                                                locator=php_intifx_get_blobloc(bid,&EG(regular_list) TSRMLS_CC);
                                        } else {
-                                               blobfilename=php_intifx_create_tmpfile(i TSRMLS_CC);
-                                               bid=php_intifx_create_blob(TYPE_BLBYTE,BLMODE_INFILE, blobfilename,strlen(blobfilename),&EG(regular_list) TSRMLS_CC);
+                                               bid=php_intifx_create_blob(TYPE_BLBYTE,BLMODE_INFILE, "",-1,&EG(regular_list) TSRMLS_CC);
                                                locator=php_intifx_get_blobloc(bid,&EG(regular_list) TSRMLS_CC);
-                                               locator->loc_oflags=LOC_WONLY;
                                        }
                                        EXEC SQL SET DESCRIPTOR :descrpid VALUE :i DATA = :*locator;
                                } 
+
+                               php_intifx_release_blob(locator TSRMLS_C);
 $ifdef HAVE_IFX_IUS;
                                if(fieldtype==SQLUDTFIXED) {
                                        bid = php_intifxus_new_slob(&EG(regular_list) TSRMLS_CC);
@@ -1066,6 +1136,7 @@ EXEC SQL BEGIN DECLARE SECTION;
        char cursorid[32];        /* query cursor id   */
        char statemid[32];        /* statement id      */
        char descrpid[32];        /* descriptor id     */
+       char i_descrpid[32];      /* input descriptor binding */
        char *statement;          /* query text        */
        int  fieldcount;          /* field count       */
        int  i;                   /* field index       */
@@ -1077,6 +1148,7 @@ EXEC SQL BEGIN DECLARE SECTION;
        int  indicator;    
        long sqlerrd[6];
        int e;
+       int desc_count;
 EXEC SQL END DECLARE SECTION;
 
        int  ctype;
@@ -1085,6 +1157,7 @@ EXEC SQL END DECLARE SECTION;
        int  cursoryproc;
        int  argc=ZEND_NUM_ARGS();
        long ifx_type;
+       int num_params;
 
        if(argc < 2 || zend_get_parameters_ex(argc, &query, &ifx_link, &dummy, &dummy)==FAILURE) {
                WRONG_PARAM_COUNT;
@@ -1102,6 +1175,7 @@ EXEC SQL END DECLARE SECTION;
        sprintf(statemid, "statem%x", IFXG(cursorid)); 
        sprintf(cursorid, "cursor%x", IFXG(cursorid)); 
        sprintf(descrpid, "descrp%x", IFXG(cursorid)); 
+       sprintf(i_descrpid, "i_descrp%x", IFXG(cursorid));
 
        EXEC SQL set connection :ifx;
        PHP_IFX_CHECK_CONNECTION(ifx);
@@ -1109,49 +1183,67 @@ EXEC SQL END DECLARE SECTION;
        EXEC SQL PREPARE :statemid FROM :statement;
        if (ifx_check() < 0) {
                IFXG(sv_sqlcode) = SQLCODE;
-               php_error(E_WARNING, "%s(): Prepare fails (%s)", get_active_function_name(TSRMLS_C), ifx_error(ifx));
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Prepare fails (%s)", ifx_error(ifx));
                RETURN_FALSE;
        }
 
        affected_rows = sqlca.sqlerrd[0];       /* save estimated affected rows */
        for (e = 0; e < 6; e++) sqlerrd[e] = sqlca.sqlerrd[e];
 
-       EXEC SQL ALLOCATE DESCRIPTOR :descrpid WITH MAX 384;
-       if (ifx_check() < 0) {
-               IFXG(sv_sqlcode) = SQLCODE;
-               php_error(E_WARNING, "%s(): Allocate desciptor <%s> fails (%s)", get_active_function_name(TSRMLS_C), descrpid, ifx_error(ifx));
+       num_params = php_intifx_preparse(statement);
+
+       Ifx_Result = (IFX_RES *) emalloc(sizeof(IFX_RES));
+       if (Ifx_Result == NULL) {
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Out of memory allocating IFX_RES");
                EXEC SQL free :statemid;
                RETURN_FALSE;
        }
-       
-       EXEC SQL DESCRIBE :statemid USING SQL DESCRIPTOR :descrpid;
-       if (ifx_check() < 0) {
+
+       /* initialize result data structure */
+
+       Ifx_Result->rowid = 0;
+       strcpy(Ifx_Result->connecid, ifx);
+       strcpy(Ifx_Result->cursorid, cursorid);
+       strcpy(Ifx_Result->descrpid, descrpid);
+       strcpy(Ifx_Result->i_descrpid, i_descrpid);
+       strcpy(Ifx_Result->statemid, statemid);
+       Ifx_Result->numcols = 0;
+       Ifx_Result->numicols = 0;
+
+       for (i = 0; i < MAX_RESID; ++i) {
+               Ifx_Result->res_id[i] = -1;
+       }
+
+       if (!php_intifx_alloc_ibind(Ifx_Result, num_params))   {
                IFXG(sv_sqlcode) = SQLCODE;
-               php_error(E_WARNING, "%s(): Describe fails (%s)", get_active_function_name(TSRMLS_C), ifx_error(ifx));
-               EXEC SQL DEALLOCATE DESCRIPTOR :descrpid;
                EXEC SQL free :statemid;
+               efree(Ifx_Result);
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Allocate i_desciptor <%s> fails (%s)", i_descrpid, ifx_error(ifx));
                RETURN_FALSE;
        }
 
-       query_type = sqlca.sqlcode;
+       desc_count = php_intifx_count_descriptors(statemid);
+       if (desc_count == 0)
+               desc_count = 1;
 
-       Ifx_Result = (IFX_RES *) emalloc(sizeof(IFX_RES));
-       if (Ifx_Result == NULL) { 
+       EXEC SQL ALLOCATE DESCRIPTOR :descrpid WITH MAX :desc_count;
+       if (ifx_check() < 0) {
+               IFXG(sv_sqlcode) = SQLCODE;
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Allocate desciptor <%s> fails (%s)", descrpid, ifx_error(ifx));
+               EXEC SQL free :statemid;
+               RETURN_FALSE;
+       }
+       
+       EXEC SQL DESCRIBE :statemid USING SQL DESCRIPTOR :descrpid;
+       if (ifx_check() < 0) {
                IFXG(sv_sqlcode) = SQLCODE;
-               php_error(E_WARNING, "%s(): Out of memory allocating IFX_RES", get_active_function_name(TSRMLS_C));
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Describe fails (%s)", ifx_error(ifx));
                EXEC SQL DEALLOCATE DESCRIPTOR :descrpid;
                EXEC SQL free :statemid;
                RETURN_FALSE;
        }
 
-       /* initialize result data structure */
-       Ifx_Result->rowid = 0;
-       strcpy(Ifx_Result->connecid, ifx); 
-       strcpy(Ifx_Result->descrpid, descrpid);
-       strcpy(Ifx_Result->statemid, statemid);
-       for (i = 0; i < MAX_RESID; ++i) {
-               Ifx_Result->res_id[i] = -1;
-       }
+       query_type = sqlca.sqlcode;
 
        cursoryproc = 0;
        if (query_type == SQ_EXECPROC) {
@@ -1171,10 +1263,10 @@ EXEC SQL END DECLARE SECTION;
                */
                zval **pblobidarr, **tmp;
 
+               /* We don't need this descriptor anymore, NONSELECT-STATEMENT */
+               EXEC SQL DEALLOCATE DESCRIPTOR :descrpid;
+
                Ifx_Result->iscursory = 0;
-               strcpy(Ifx_Result->cursorid, cursorid);
-               strcpy(Ifx_Result->cursorid, "");
-               strcpy(Ifx_Result->descrpid, descrpid);
 
                if(argc > 3) {
                        WRONG_PARAM_COUNT;
@@ -1182,31 +1274,36 @@ EXEC SQL END DECLARE SECTION;
 
                if(argc == 3) {
                        Ifx_Result->paramquery=1;
+
+                       if (Ifx_Result->numicols <= 0)   {
+                               IFXG(sv_sqlcode) = SQLCODE;
+                               EXEC SQL free :statemid;
+                               efree(Ifx_Result);
+                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "No placeholders (?) in Statement, but blob array param supplied");
+                               RETURN_FALSE;
+                       }
+
                        if (zend_get_parameters_ex(3, &dummy, &dummy,&pblobidarr) == FAILURE) {
                                IFXG(sv_sqlcode) = SQLCODE;
-                               EXEC SQL DEALLOCATE DESCRIPTOR :descrpid;
+                               EXEC SQL DEALLOCATE DESCRIPTOR :i_descrpid;
                                EXEC SQL free :statemid;
                                efree(Ifx_Result);
-                               php_error(E_WARNING,"%s(): Can't get blob array param", get_active_function_name(TSRMLS_C));
+                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can't get blob array param");
                                RETURN_FALSE;
                        }
 
                        if((*pblobidarr)->type != IS_ARRAY) {
                                IFXG(sv_sqlcode) = SQLCODE;
-                               EXEC SQL DEALLOCATE DESCRIPTOR :descrpid;
+                               EXEC SQL DEALLOCATE DESCRIPTOR :i_descrpid;
                                EXEC SQL free :statemid;
                                efree(Ifx_Result);
-                               php_error(E_WARNING, "%s(): Blob-parameter not an array", get_active_function_name(TSRMLS_C));
+                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Blob-parameter not an array");
                                RETURN_FALSE;
                        } 
 
                        zend_hash_internal_pointer_reset((*pblobidarr)->value.ht);
-                       i=1;
-                       while (zend_hash_get_current_data((*pblobidarr)->value.ht, (void **) &tmp) == SUCCESS) {
+                       for (i = 1; i <= num_params && (zend_hash_get_current_data((*pblobidarr)->value.ht, (void **) &tmp) == SUCCESS); ++i) {
                                convert_to_long(*tmp);
-                               if ((query_type == SQ_UPDATE) || (query_type == SQ_UPDALL)) {
-                                       EXEC SQL SET DESCRIPTOR :descrpid COUNT = :i;
-                               }
                                
                                ifx_type=php_intifx_getType((int)(*tmp)->value.lval,&EG(regular_list) TSRMLS_CC);
                                switch(ifx_type) {
@@ -1215,16 +1312,16 @@ EXEC SQL END DECLARE SECTION;
                                                locator=php_intifx_get_blobloc((int)((*tmp)->value.lval),&EG(regular_list) TSRMLS_CC);
                                                if(locator==NULL) {
                                                        IFXG(sv_sqlcode) = SQLCODE;
-                                                       EXEC SQL DEALLOCATE DESCRIPTOR :descrpid;
+                                                       EXEC SQL DEALLOCATE DESCRIPTOR :i_descrpid;
                                                        EXEC SQL free :statemid;
                                                        efree(Ifx_Result);
-                                                       php_error(E_WARNING, "%s(): %d is not a Informix blob-result index", get_active_function_name(TSRMLS_C), (int)((*tmp)->value.lval));
+                                                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "%d is not a Informix blob-result index", (int)((*tmp)->value.lval));
                                                        RETURN_FALSE;
                                                }
                                                if(locator->loc_loctype==LOCFNAME) {
                                                        locator->loc_oflags=LOC_RONLY;
                                                }
-                                               EXEC SQL SET DESCRIPTOR :descrpid VALUE :i DATA= :*locator, TYPE=:loc_t_type; 
+                                               EXEC SQL SET DESCRIPTOR :i_descrpid VALUE :i DATA = :*locator, TYPE = :loc_t_type;
                                                break;
                                        case TYPE_CHAR:
                                                len=php_intifx_get_char((int)((*tmp)->value.lval),&EG(regular_list),&char_tmp TSRMLS_CC);
@@ -1242,9 +1339,27 @@ EXEC SQL END DECLARE SECTION;
                                                        TYPE= :sqlchar_type;
                                                break;
                                }
-                               i++;
+
+                               if (ifx_check() < 0)   {
+                                       IFXG(sv_sqlcode) = SQLCODE;
+                                       EXEC SQL DEALLOCATE DESCRIPTOR :i_descrpid;
+                                       EXEC SQL free :statemid;
+                                       efree(Ifx_Result);
+                                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Prepare fails : %s", ifx_error(ifx));
+                                       RETURN_FALSE;
+                               }
+
                                zend_hash_move_forward((*pblobidarr)->value.ht);
                        } 
+
+                       if (i - 1 != Ifx_Result->numicols)   {
+                               EXEC SQL DEALLOCATE DESCRIPTOR :i_descrpid;
+                               EXEC SQL free :statemid;
+                               efree(Ifx_Result);
+                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Prepare fails : number of created blobs doesn't match placeholders (?)");
+                               RETURN_FALSE;
+                       }
+
                }
 
                Ifx_Result->affected_rows = affected_rows;   /* saved estimated from prepare */
@@ -1272,7 +1387,6 @@ EXEC SQL END DECLARE SECTION;
                                break;
                }
                
-               strcpy(Ifx_Result->cursorid, cursorid);
                Ifx_Result->iscursory = 1;
 
                Ifx_Result->affected_rows = affected_rows;   /* saved estimated from prepare */
@@ -1284,7 +1398,7 @@ EXEC SQL END DECLARE SECTION;
                        EXEC SQL DEALLOCATE DESCRIPTOR :descrpid;
                        EXEC SQL free :statemid;
                        efree(Ifx_Result);
-                       php_error(E_WARNING, "%s(): Can not get descriptor %s (%s)", get_active_function_name(TSRMLS_C), descrpid, ifx_error(ifx));
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can not get descriptor %s (%s)", descrpid, ifx_error(ifx));
                        RETURN_FALSE;
                }
                Ifx_Result->numcols = fieldcount;
@@ -1326,6 +1440,7 @@ EXEC SQL BEGIN DECLARE SECTION;
        char *cursorid;           /* query cursor id   */
        char *statemid;           /* statement id      */
        char *descrpid;           /* descriptor id     */
+       char *i_descrpid;         /* descriptor id     */
        int  fieldcount;          /* field count       */
        int  i;                   /* field index       */
        short fieldtype;
@@ -1337,7 +1452,6 @@ $endif;
 EXEC SQL END DECLARE SECTION;
 
        int  locind;
-       char *blobfilename;
 
        if(ZEND_NUM_ARGS() != 1 || (zend_get_parameters_ex(1, &result)==FAILURE)) {
                WRONG_PARAM_COUNT;
@@ -1351,25 +1465,26 @@ EXEC SQL END DECLARE SECTION;
        cursorid   = Ifx_Result->cursorid;
        statemid   = Ifx_Result->statemid;
        descrpid   = Ifx_Result->descrpid;
+       i_descrpid   = Ifx_Result->i_descrpid;
        fieldcount = Ifx_Result->numcols;
 
        EXEC SQL set connection :ifx;
        PHP_IFX_CHECK_CONNECTION(ifx);
        
        if (Ifx_Result->iscursory < 0) {
-               php_error(E_WARNING, "%s(): Resultindex %d is not a prepared query", get_active_function_name(TSRMLS_C), Z_LVAL_PP(result));
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Resultindex %d is not a prepared query", Z_LVAL_PP(result));
                RETURN_FALSE;
        }
 
        if (Ifx_Result->iscursory==0) {         /* execute immediate */
                if(Ifx_Result->paramquery!=0) {
-                       EXEC SQL EXECUTE :statemid USING SQL DESCRIPTOR :descrpid;
+                       EXEC SQL EXECUTE :statemid USING SQL DESCRIPTOR :i_descrpid;
                } else {
                        EXEC SQL EXECUTE :statemid;
                }
                if (ifx_check() < 0) {
                        IFXG(sv_sqlcode) = SQLCODE;
-                       php_error(E_WARNING, "%s(): Execute immediate fails: %s", get_active_function_name(TSRMLS_C), ifx_error(ifx));
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Execute immediate fails: %s", ifx_error(ifx));
                        RETURN_FALSE;
                }
                Ifx_Result->affected_rows = sqlca.sqlerrd[2]; /* really affected */
@@ -1391,14 +1506,14 @@ EXEC SQL END DECLARE SECTION;
 
                if (ifx_check() < 0) {
                        IFXG(sv_sqlcode) = SQLCODE;
-                       php_error(E_WARNING, "%s(): Declare cursor fails (%s)", get_active_function_name(TSRMLS_C), ifx_error(ifx));
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Declare cursor fails (%s)", ifx_error(ifx));
                        RETURN_FALSE;
                }
 
                EXEC SQL OPEN :cursorid;
                if (ifx_check() < 0) {
                        IFXG(sv_sqlcode) = SQLCODE;
-                       php_error(E_WARNING, "%s(): Open cursor fails (%s)", get_active_function_name(TSRMLS_C), ifx_error(ifx));
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Open cursor fails (%s)", ifx_error(ifx));
                        RETURN_FALSE;
                }
 
@@ -1414,22 +1529,29 @@ $endif;
 
                                int bid = 0;
                                if(fieldtype==SQLTEXT) {
-                                       bid=php_intifx_create_blob(TYPE_BLTEXT,BLMODE_INMEM,"",-1,&EG(regular_list) TSRMLS_CC);
-                                       locator=php_intifx_get_blobloc(bid,&EG(regular_list) TSRMLS_CC);
+                                       if(IFXG(blobinfile)==0) {
+                                               bid=php_intifx_create_blob(TYPE_BLTEXT,BLMODE_INMEM,"",-1,&EG(regular_list) TSRMLS_CC);
+                                               locator=php_intifx_get_blobloc(bid,&EG(regular_list) TSRMLS_CC);
+                                       } else {
+                                               bid=php_intifx_create_blob(TYPE_BLTEXT,BLMODE_INFILE,"", -1,&EG(regular_list) TSRMLS_CC);
+                                               locator=php_intifx_get_blobloc(bid,&EG(regular_list) TSRMLS_CC);
+                                       }
+                                       
                                        EXEC SQL SET DESCRIPTOR :descrpid VALUE :i DATA = :*locator;
                                }
-                               if(fieldtype==SQLBYTES) {
+                               else if(fieldtype==SQLBYTES) {
                                        if(IFXG(blobinfile)==0) {
                                                bid=php_intifx_create_blob(TYPE_BLBYTE,BLMODE_INMEM,"",-1,&EG(regular_list) TSRMLS_CC);
                                                locator=php_intifx_get_blobloc(bid,&EG(regular_list) TSRMLS_CC);
                                        } else {
-                                               blobfilename=php_intifx_create_tmpfile(i TSRMLS_CC);
-                                               bid=php_intifx_create_blob(TYPE_BLBYTE,BLMODE_INFILE,blobfilename,strlen(blobfilename),&EG(regular_list) TSRMLS_CC);
+                                               bid=php_intifx_create_blob(TYPE_BLBYTE,BLMODE_INFILE,"", -1,&EG(regular_list) TSRMLS_CC);
                                                locator=php_intifx_get_blobloc(bid,&EG(regular_list) TSRMLS_CC);
                                                locator->loc_oflags=LOC_WONLY;
                                        }
                                        EXEC SQL SET DESCRIPTOR :descrpid VALUE :i DATA = :*locator;
                                }
+
+                               php_intifx_release_blob(locator TSRMLS_C);
 $ifdef HAVE_IFX_IUS;
                                if(fieldtype==SQLUDTFIXED) {
                                        bid=php_intifxus_new_slob(&EG(regular_list) TSRMLS_CC);
@@ -1625,7 +1747,6 @@ EXEC SQL END DECLARE SECTION;
        char string_data[256];
        long long_data;
        char *p;
-       char *blobfilename;
        char *fetch_pos;
        char *nullstr;
 
@@ -1660,7 +1781,7 @@ EXEC SQL END DECLARE SECTION;
        IFXG(sv_sqlcode) = 0;
 
        if (strcmp(Ifx_Result->cursorid,"") == 0) {
-               php_error(E_WARNING, "%s(): Not a select cursor!", get_active_function_name(TSRMLS_C));
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Not a select cursor!");
                RETURN_FALSE;
        }
        
@@ -1673,6 +1794,32 @@ EXEC SQL END DECLARE SECTION;
        EXEC SQL set connection :ifx;
        PHP_IFX_CHECK_CONNECTION(ifx);
 
+       locind = 0;
+       for (i = 1; i <= Ifx_Result->numcols; i++)   {
+               
+               EXEC SQL GET DESCRIPTOR :descrpid VALUE :i :fieldtype = TYPE;
+               if (fieldtype == SQLBYTES || fieldtype == SQLTEXT)   {
+
+                       bid_b = Ifx_Result->res_id[locind];
+
+                       if ((locator_b = php_intifx_get_blobloc(bid_b, &EG(regular_list) TSRMLS_C)) == NULL)   {
+                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cant get BLOB from Result Set!");
+                               RETURN_FALSE;
+                       }
+
+                       locind++;
+
+                       if(IFXG(blobinfile)==0)   {
+                               php_intifx_init_blob(locator_b, BLMODE_INMEM, 1);
+                       } else {
+                               php_intifx_init_blob(locator_b, BLMODE_INFILE, 1);
+                       }
+
+                       EXEC SQL SET DESCRIPTOR :descrpid VALUE :i DATA = :*locator_b;
+
+               }
+       }
+                       
        if (!Ifx_Result->isscroll) {
                EXEC SQL FETCH :cursorid USING SQL DESCRIPTOR :descrpid;
        } else {
@@ -1694,7 +1841,7 @@ EXEC SQL END DECLARE SECTION;
                        } else if (!strcasecmp(fetch_pos,"CURRENT")) {
                                EXEC SQL FETCH CURRENT  :cursorid USING SQL DESCRIPTOR :descrpid;
                        } else {
-                               php_error(E_WARNING, "%s(): Invalid positioning arg on fetch", get_active_function_name(TSRMLS_C));
+                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid positioning arg on fetch");
                        }
                }
        }  
@@ -1703,7 +1850,7 @@ EXEC SQL END DECLARE SECTION;
                switch (ifx_check()) {
                        case IFX_ERROR:
                                IFXG(sv_sqlcode) = SQLCODE;
-                               php_error(E_WARNING, "%s(): Can not fetch row on cursor %s (%s)", get_active_function_name(TSRMLS_C), ifx_error(ifx), cursorid);
+                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can not fetch row on cursor %s (%s)", ifx_error(ifx), cursorid);
                                RETURN_FALSE;
                                break;
                        case IFX_NODATA:
@@ -1715,9 +1862,7 @@ EXEC SQL END DECLARE SECTION;
        }
        Ifx_Result->rowid++;
 
-       if (array_init(return_value)==FAILURE) {
-               RETURN_FALSE;
-       }
+       array_init(return_value);
        num_fields = fieldcount;
 
        locind = 0;
@@ -1730,7 +1875,7 @@ EXEC SQL END DECLARE SECTION;
 
                if (ifx_check() < 0) {
                        IFXG(sv_sqlcode) = SQLCODE;
-                       php_error(E_WARNING, "%s(): Get descriptor (field # %d) fails (%s)", get_active_function_name(TSRMLS_C), i, ifx_error(ifx));
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Get descriptor (field # %d) fails (%s)", i, ifx_error(ifx));
                        RETURN_FALSE;
                }
 
@@ -1745,10 +1890,13 @@ EXEC SQL END DECLARE SECTION;
                        if(     (IFXG(textasvarchar)==0 && fieldtype==SQLTEXT) || 
                                (IFXG(byteasvarchar)==0 && fieldtype==SQLBYTES)) {
                                bid_b=Ifx_Result->res_id[locind];
+                               /* call php_intifx_get_blobloc() to reset locator_b */
+                               locator_b=php_intifx_get_blobloc(bid_b,&EG(regular_list) TSRMLS_CC);
                                bid=php_intifx_copy_blob(bid_b, &EG(regular_list) TSRMLS_CC);
                                php_intifx_update_blob(bid,nullstr,strlen(nullstr),&EG(regular_list) TSRMLS_CC);
                                add_assoc_long(return_value,fieldname,bid);
                                ++locind;
+                               php_intifx_release_blob(locator_b TSRMLS_CC);
                                continue; 
                        }
                        if ((fieldtype==SQLTEXT) || (fieldtype==SQLBYTES)
@@ -1756,7 +1904,11 @@ $ifdef HAVE_IFX_IUS;
                        || (fieldtype==SQLUDTFIXED)
 $endif;
                        ) {
+                               /* call php_intifx_get_blobloc() to reset locator_b */
+                               bid_b=Ifx_Result->res_id[locind];
+                               locator_b=php_intifx_get_blobloc(bid_b,&EG(regular_list) TSRMLS_CC);
                                ++locind;
+                               php_intifx_release_blob(locator_b TSRMLS_CC);
                        }
                        add_assoc_string(return_value, fieldname, nullstr, DUP);
                        continue;
@@ -1828,7 +1980,7 @@ $ifdef HAVE_IFX_IUS;
                                fieldleng=ifx_var_getlen(&lvar_tmp);
                                if (fieldleng > 2) fieldleng -= 2; /* fix by Alex Shepherd */
                                if ((char_data = (char *)emalloc(fieldleng + 1)) == NULL) {
-                                       php_error(E_WARNING, "%s(): Out of memory", get_active_function_name(TSRMLS_C));
+                                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Out of memory");
                                        RETURN_FALSE;
                                }
                                memcpy(char_data,ifx_var_getdata(&lvar_tmp),fieldleng);
@@ -1842,7 +1994,7 @@ $endif;
                        case SQLCHAR     :
                        case SQLNCHAR    :
                                if ((char_data = (char *)emalloc(fieldleng + 1)) == NULL) {
-                                       php_error(E_WARNING, "%s(): Out of memory", get_active_function_name(TSRMLS_C));
+                                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Out of memory");
                                        RETURN_FALSE;
                                }
                                EXEC SQL GET DESCRIPTOR :descrpid VALUE :i :char_data = DATA;
@@ -1869,6 +2021,13 @@ $endif;
                                bid_b=Ifx_Result->res_id[locind];
                                locator_b=php_intifx_get_blobloc(bid_b,&EG(regular_list) TSRMLS_CC); 
                                ++locind;
+
+                               if(IFXG(blobinfile)==0)   {
+                                       php_intifx_init_blob(locator_b, BLMODE_INMEM, 0);
+                               } else {
+                                       php_intifx_init_blob(locator_b, BLMODE_INFILE, 0);
+                               }
+
                                EXEC SQL GET DESCRIPTOR :descrpid VALUE :i :*locator_b = DATA;
                                
                                /* work around for ESQL/C bug with NULL values and BLOBS */
@@ -1880,10 +2039,10 @@ $endif;
                                if (locator_b->loc_indicator == -1) { 
                                        if((IFXG(textasvarchar)==0 && fieldtype==SQLTEXT) 
                                        || (IFXG(byteasvarchar)==0 && fieldtype==SQLBYTES)) {
-                                               bid_b=Ifx_Result->res_id[locind];
                                                bid=php_intifx_copy_blob(bid_b, &EG(regular_list) TSRMLS_CC);
                                                php_intifx_update_blob(bid,nullstr,strlen(nullstr),&EG(regular_list) TSRMLS_CC);
                                                add_assoc_long(return_value,fieldname,bid);
+                                               php_intifx_release_blob(locator_b TSRMLS_CC);
                                                break; 
                                        }
                                        if ((fieldtype==SQLTEXT) || (fieldtype==SQLBYTES)
@@ -1892,26 +2051,16 @@ $ifdef HAVE_IFX_IUS;
 $endif;
                                        ) {
                                                add_assoc_string(return_value, fieldname, nullstr, DUP);
+                                               php_intifx_release_blob(locator_b TSRMLS_CC);
                                                break;
                                        }
                                }
                
                                if (locator_b->loc_status < 0) {  /* blob too large */   
-                                       php_error(E_WARNING, "%s(): No memory (%d bytes) for blob", get_active_function_name(TSRMLS_C), locator_b->loc_bufsize);
+                                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "No memory (%d bytes) for blob", locator_b->loc_bufsize);
                                        RETURN_FALSE;
                                }
                
-                               /* copy blob */
-                               bid=php_intifx_copy_blob(bid_b, &EG(regular_list) TSRMLS_CC);
-
-                               /* and generate new tempfile for next row */
-                               if(locator_b->loc_loctype==LOCFNAME) {
-                                       blobfilename=php_intifx_create_tmpfile(bid_b TSRMLS_CC);
-                                       php_intifx_update_blob(bid_b,blobfilename,strlen(blobfilename),&EG(regular_list) TSRMLS_CC);
-                                       efree(blobfilename);
-                                       EXEC SQL SET DESCRIPTOR :descrpid VALUE :i DATA= :*locator_b;
-                               } 
                                /* return blob as VARCHAR ?  */
                                /* note that in case of "blobinfile" */
                                /* you get the file name */
@@ -1924,18 +2073,26 @@ $endif;
                                        char *content;
                                        long lg;
                        
-                                       lg=php_intifx_get_blob(bid, &EG(regular_list), &content TSRMLS_CC);
+                                       lg=php_intifx_get_blob(bid_b, &EG(regular_list), &content TSRMLS_CC);
                                        if(content == NULL || lg < 0) {
                                                add_assoc_string(return_value,fieldname,nullstr,DUP);
                                        } else {
                                                add_assoc_stringl(return_value,fieldname,content,lg,DUP);
                                        }
-                                       php_intifx_free_blob(bid, &EG(regular_list) TSRMLS_CC);
+                                       
+                                       php_intifx_release_blob(locator_b TSRMLS_C);
                                        break;
                                } 
 
+                               /* copy blob */
+                               bid=php_intifx_copy_blob(bid_b, &EG(regular_list) TSRMLS_CC);
+
                                /* no, return as blob id */
                                add_assoc_long(return_value,fieldname,bid);
+
+                               php_intifx_release_blob(locator_b TSRMLS_C);
+                       
+                               
                                break;
                        default  :
                                sprintf(string_data,"ESQL/C : %s : unsupported field type[%d]", fieldname, fieldleng);
@@ -2026,7 +2183,7 @@ EXEC SQL END DECLARE SECTION;
        ZEND_FETCH_RESOURCE(Ifx_Result, IFX_RES *, result, -1, "Informix Result", le_result);
 
        if (strcmp(Ifx_Result->cursorid,"") == 0) {
-               php_error(E_WARNING, "%s(): Not a select cursor!", get_active_function_name(TSRMLS_C));
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Not a select cursor!");
                RETURN_FALSE;
        }
 
@@ -2044,7 +2201,7 @@ EXEC SQL END DECLARE SECTION;
        switch (ifx_check()) {
                case IFX_ERROR:
                        IFXG(sv_sqlcode) = SQLCODE;
-                       php_error(E_WARNING, "%s(): Can not fetch next row on cursor %s (%s)", get_active_function_name(TSRMLS_C), ifx_error(ifx), cursorid);
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can not fetch next row on cursor %s (%s)", ifx_error(ifx), cursorid);
                        RETURN_FALSE;
                        break;
                case IFX_NODATA:
@@ -2074,7 +2231,7 @@ EXEC SQL END DECLARE SECTION;
                EXEC SQL GET DESCRIPTOR :descrpid VALUE :i :fieldname = NAME;
                if (ifx_check() < 0) {
                        IFXG(sv_sqlcode) = SQLCODE;
-                       php_error(E_WARNING, "%s(): Get descriptor (field # %d) fails (%s)", get_active_function_name(TSRMLS_C), i, ifx_error(ifx));
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Get descriptor (field # %d) fails (%s)", i, ifx_error(ifx));
                        RETURN_FALSE;
                }
 
@@ -2101,7 +2258,7 @@ EXEC SQL END DECLARE SECTION;
 
                        if (ifx_check() < 0) {
                                IFXG(sv_sqlcode) = SQLCODE;
-                               php_error(E_WARNING, "%s(): Get descriptor (field # %d) fails (%s)", get_active_function_name(TSRMLS_C), i, ifx_error(ifx));
+                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Get descriptor (field # %d) fails (%s)", i, ifx_error(ifx));
                                RETURN_FALSE;
                        }
                
@@ -2180,7 +2337,7 @@ $ifdef HAVE_IFX_IUS;
                                        if (fieldleng > 2) fieldleng -= 2; /* fix by Alex Shepherd */
 
                                        if ((char_data = (char *)emalloc(fieldleng + 1)) == NULL) {
-                                               php_error(E_WARNING, "%s(): Out of memory", get_active_function_name(TSRMLS_C));
+                                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Out of memory");
                                                RETURN_FALSE;
                                        }
                                        memcpy(char_data,ifx_var_getdata(&lvar_tmp),fieldleng);
@@ -2194,7 +2351,7 @@ $endif;
                                case SQLNCHAR   :
                                case SQLNVCHAR  :
                                        if ((char_data = (char *)emalloc(fieldleng + 1)) == NULL) {
-                                               php_error(E_WARNING, "%s(): Out of memory", get_active_function_name(TSRMLS_C));
+                                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Out of memory");
                                                RETURN_FALSE;
                                        }
                                        EXEC SQL GET DESCRIPTOR :descrpid VALUE :i :char_data = DATA;
@@ -2230,7 +2387,7 @@ $endif;
                                                }
                                        }
                                        if (locator_b->loc_status < 0) {  /* blob too large */   
-                                               php_error(E_WARNING, "%s(): Not enough memory (%d bytes) for blob", get_active_function_name(TSRMLS_C), locator_b->loc_bufsize);
+                                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Not enough memory (%d bytes) for blob", locator_b->loc_bufsize);
                                                RETURN_FALSE;
                                        }
 
@@ -2243,7 +2400,7 @@ $endif;
                                                /* need an extra byte for string terminator */
                                                copy_content = malloc(lg + 1);
                                                if (copy_content == NULL) {
-                                                       php_error(E_WARNING, "%s(): Not enough memory for TEXT column", get_active_function_name(TSRMLS_C));
+                                                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Not enough memory for TEXT column");
                                                        RETURN_FALSE;
                                                }
                                                memcpy(copy_content, content, lg);
@@ -2270,7 +2427,7 @@ $endif;
                switch (ifx_check()) {
                        case IFX_ERROR:
                                IFXG(sv_sqlcode) = SQLCODE;
-                               php_error(E_WARNING, "%s(): Can not fetch next row on cursor %s (%s)", get_active_function_name(TSRMLS_C), ifx_error(ifx), cursorid);
+                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can not fetch next row on cursor %s (%s)", ifx_error(ifx), cursorid);
                                RETURN_FALSE;
                                break;
                        case IFX_NODATA:
@@ -2326,7 +2483,7 @@ EXEC SQL END DECLARE SECTION;
        ZEND_FETCH_RESOURCE(Ifx_Result, IFX_RES *, result, -1, "Informix Result", le_result);
 
        if (strcmp(Ifx_Result->cursorid,"") == 0) {
-               php_error(E_WARNING, "%s(): Not a select cursor!", get_active_function_name(TSRMLS_C));
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Not a select cursor!");
                RETURN_FALSE;
        }
 
@@ -2339,15 +2496,13 @@ EXEC SQL END DECLARE SECTION;
        EXEC SQL set connection :ifx;
        PHP_IFX_CHECK_CONNECTION(ifx);
 
-       if (array_init(return_value)==FAILURE) {
-               RETURN_FALSE;
-       }
+       array_init(return_value);
        num_fields = fieldcount;
        for (i = 1; i <= num_fields; i++) {
                EXEC SQL GET DESCRIPTOR :descrpid VALUE :i :fieldname = NAME, :fieldtype = TYPE;
                if (ifx_check() < 0) {
                        IFXG(sv_sqlcode) = SQLCODE;
-                       php_error(E_WARNING, "%s(): Get descriptor (field # %d) fails (%s)", get_active_function_name(TSRMLS_C), i, ifx_error(ifx));
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Get descriptor (field # %d) fails (%s)", i, ifx_error(ifx));
                        RETURN_FALSE;
                }
 
@@ -2484,7 +2639,7 @@ EXEC SQL END DECLARE SECTION;
        ZEND_FETCH_RESOURCE(Ifx_Result, IFX_RES *, result, -1, "Informix Result", le_result);
 
        if (strcmp(Ifx_Result->cursorid,"") == 0) {
-               php_error(E_WARNING, "%s(): Not a select cursor!", get_active_function_name(TSRMLS_C));
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Not a select cursor!");
                RETURN_FALSE;
        }
 
@@ -2497,9 +2652,7 @@ EXEC SQL END DECLARE SECTION;
        EXEC SQL set connection :ifx;
        PHP_IFX_CHECK_CONNECTION(ifx);
 
-       if (array_init(return_value)==FAILURE) {
-               RETURN_FALSE;
-       }
+       array_init(return_value);
        num_fields = fieldcount;
 
        for (i = 1; i <= num_fields; i++) {
@@ -2512,7 +2665,7 @@ EXEC SQL END DECLARE SECTION;
 
                if (ifx_check() < 0) {
                        IFXG(sv_sqlcode) = SQLCODE;
-                       php_error(E_WARNING, "%s(): Get descriptor (field # %d) fails (%s)", get_active_function_name(TSRMLS_C), i, ifx_error(ifx));
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Get descriptor (field # %d) fails (%s)", i, ifx_error(ifx));
                        RETURN_FALSE;
                }
                
@@ -2655,9 +2808,7 @@ PHP_FUNCTION(ifx_getsqlca)
        ZEND_FETCH_RESOURCE(Ifx_Result, IFX_RES *, result, -1, "Informix Result", le_result);
 
        /* create pseudo-row array to return */
-       if (array_init(return_value)==FAILURE) {
-               RETURN_FALSE;
-       }
+       array_init(return_value);
        
        /* fill array with 6 fields sqlerrd0 .. sqlerrd5 */
        /* each ESQLC call saves these sqlca values  */
@@ -2730,7 +2881,7 @@ EXEC SQL END DECLARE SECTION;
 
        for (i = 0; i < MAX_RESID; ++i) {
                if (Ifx_Result->res_id[i]>0) {
-                       php_intifx2_free_blob(Ifx_Result->res_id[i],&EG(regular_list) TSRMLS_CC);
+                       zend_list_delete(Ifx_Result->res_id[i]);
                        Ifx_Result->res_id[i]=-1;
                }
        }
@@ -2775,7 +2926,7 @@ static long php_intifx_getType(long id, HashTable *list TSRMLS_DC)
 
        Ifx_res = (IFX_IDRES *) zend_list_find(id,&type);
        if (type!=le_idresult) {
-               php_error(E_WARNING, "%s(): %d is not a Informix id-result index", get_active_function_name(TSRMLS_C), id);
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "%d is not a Informix id-result index", id);
                return -1;
        }
        return Ifx_res->type;
@@ -2797,29 +2948,29 @@ static long php_intifx_getType(long id, HashTable *list TSRMLS_DC)
    Creates a blob-object */
 PHP_FUNCTION(ifx_create_blob) 
 {
-       zval *pmode, *pparam,*ptype;
+       zval **pmode, **pparam,**ptype;
        long id;
        long mode,type;
   
-       if (ZEND_NUM_ARGS()!=3 || getParameters(ht, 3, &ptype,&pmode,&pparam)==FAILURE) {
+       if (ZEND_NUM_ARGS() !=3 || zend_get_parameters_ex(3, &ptype,&pmode,&pparam) == FAILURE) {
                WRONG_PARAM_COUNT;
        }
 
-       convert_to_long(pmode);
-       convert_to_string(pparam);
-       convert_to_long(ptype);
+       convert_to_long_ex(pmode);
+       convert_to_string_ex(pparam);
+       convert_to_long_ex(ptype);
 
-       type=Z_LVAL_P(ptype);
+       type = Z_LVAL_PP(ptype);
        if(type != 0) {
-               type=TYPE_BLTEXT;
+               type = TYPE_BLTEXT;
        }
 
-       mode=Z_LVAL_P(pmode);
+       mode = Z_LVAL_PP(pmode);
        if(mode != 0) {
                mode=BLMODE_INFILE;
        }
 
-       id=php_intifx_create_blob(type,mode,Z_STRVAL_P(pparam),Z_STRLEN_P(pparam),&EG(regular_list) TSRMLS_CC); 
+       id=php_intifx_create_blob(type,mode,Z_STRVAL_PP(pparam),Z_STRLEN_PP(pparam),&EG(regular_list) TSRMLS_CC); 
 
        if(id < 0) {
                RETURN_FALSE;
@@ -2832,7 +2983,7 @@ PHP_FUNCTION(ifx_create_blob)
  * internal function
  * long php_intifx_create_blob(long type, long mode, char* param, long len, HashTable *list TSRMLS_DC)
  *
- * creates an blob-object
+ * creates an blob-object for the PHP Resource list
  *  type: 1=TEXT, 0=BYTE
  *  mode: blob-object holds 0=the content in momory, 1=content in file
  *  param: if mode=0: pointer to the content
@@ -2848,7 +2999,7 @@ static long php_intifx_create_blob(long type, long mode, char* param, long len,
 
        Ifx_blob=emalloc(sizeof(IFX_IDRES));
        if(Ifx_blob==NULL) {
-               php_error(E_WARNING, "%s(): Can't create blob-resource", get_active_function_name(TSRMLS_C));
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can't create blob-resource");
                return -1;
        }
        
@@ -2861,43 +3012,163 @@ static long php_intifx_create_blob(long type, long mode, char* param, long len,
        }
        Ifx_blob->BLOB.mode=(int)mode;
 
+       if (php_intifx_init_blob(&Ifx_blob->BLOB.blob_data, mode, 1) < 0)   {
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can't create blob-resource");
+               return -1;
+       }
+
        if(mode==BLMODE_INMEM) {
                if(len>=0) {
                        char *content=emalloc(len);
                        if(content==NULL) {
-                               php_error(E_WARNING, "%s(): Can't create blob-resource", get_active_function_name(TSRMLS_C));
+                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can't create blob-resource");
                                return -1;
                        }
                        memcpy(content,param,len);
-                       Ifx_blob->BLOB.blob_data.loc_loctype=LOCMEMORY;
                        Ifx_blob->BLOB.blob_data.loc_buffer=content;
                        Ifx_blob->BLOB.blob_data.loc_bufsize=len;
                        Ifx_blob->BLOB.blob_data.loc_size=len;
-                       Ifx_blob->BLOB.blob_data.loc_mflags=0;
                        Ifx_blob->BLOB.blob_data.loc_oflags=0;
-               } else {
-                       Ifx_blob->BLOB.blob_data.loc_loctype=LOCMEMORY;
-                       Ifx_blob->BLOB.blob_data.loc_buffer=NULL;
-                       Ifx_blob->BLOB.blob_data.loc_bufsize=-1;
+               }
+       }
+       else   {
+
+               if (*param && param != "")   {
+
+                       char *filename;
+
+                       if(Ifx_blob->BLOB.blob_data.loc_fname!=NULL) {
+                               unlink(Ifx_blob->BLOB.blob_data.loc_fname);
+                               efree(Ifx_blob->BLOB.blob_data.loc_fname);
+                       }
+                       if((filename=emalloc(len+1))==NULL)  {
+                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can't create blob-resource");
+                               return -1;
+                       }
+                       memcpy(filename,param, len);
+                       filename[len]=0;
+                       Ifx_blob->BLOB.blob_data.loc_fname=filename;
                        Ifx_blob->BLOB.blob_data.loc_size=-1;
-                       Ifx_blob->BLOB.blob_data.loc_mflags=0;
-                       Ifx_blob->BLOB.blob_data.loc_oflags=0;
                }
-       } else { /* mode = BLMODE_INFILE */
-               char *filename=emalloc(len+1);
+       }
+
+       return zend_list_insert(Ifx_blob,le_idresult);
+}
+
+static long php_intifx_init_blob(loc_t *blob, long mode, long new TSRMLS_DC)   {
+       
+       if (new)   {
+               memset(blob, 0, sizeof(loc_t));
+       }
+
+       blob->loc_status = 0;
+       blob->loc_type = SQLTEXT;
+       blob->loc_xfercount = 0;
+       blob->loc_indicator = 0;
+
+       if (mode == BLMODE_INMEM)   {
+               return php_intifx_init_blob_inmem(blob, new TSRMLS_CC);
+       } else {
+               return php_intifx_init_blob_infile(blob, new TSRMLS_CC);
+       }
+
+       return 1;
+       
+}
+       
+static long php_intifx_init_blob_inmem(loc_t *blob, long new TSRMLS_DC)   {
+
+       blob->loc_loctype=LOCMEMORY;
+
+       if (new)   {
+               blob->loc_buffer=NULL;
+               blob->loc_bufsize=-1;
+               blob->loc_size=0;
+       }
+
+       blob->loc_mflags=0;
+       blob->loc_oflags=0;
+
+       return 1;
+}
+
+static long php_intifx_init_blob_infile(loc_t *blob, long new TSRMLS_DC)   {
+
+       char *filename;
+
+       if (new)   {
+
+               filename = php_intifx_create_tmpfile(TSRMLS_C);
+
                if(filename==NULL)  {
-                       php_error(E_WARNING, "%s(): Can't create blob-resource", get_active_function_name(TSRMLS_C));
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can't create blob-resource");
                        return -1;
                }
-               memcpy(filename,param,len);
-               filename[len]=0;
-               Ifx_blob->BLOB.blob_data.loc_loctype=LOCFNAME;
-               Ifx_blob->BLOB.blob_data.loc_fname=filename;
-               Ifx_blob->BLOB.blob_data.loc_oflags=LOC_WONLY;
-               Ifx_blob->BLOB.blob_data.loc_size=-1;
+
+               blob->loc_fname = filename;
+               blob->loc_size = 0;
+               blob->loc_fd = -1;
        }
-       return zend_list_insert(Ifx_blob,le_idresult);
+
+       return 1;
+}
+
+static void php_intifx_release_blob(loc_t *blob TSRMLS_DC)   {
+
+
+#if IFX_VERSION < 724 /* this Informix  memory leak is fixed from 7.24 on     */
+                      /* according to the current PERL DBD::Informix          */
+                      /* and otherwise I get segmenation violations with 7.30 */
+
+       /* Not set to NULL, so function will free resources */
+       
+#else
+
+       /* Set to NULL so php_intifx_release_blob() doens't try to free stuff it shouldn't */
+
+       if (blob->loc_loctype == LOCMEMORY)   {
+               blob->loc_buffer = NULL;
+       }
+
+#endif
+
+       switch (blob->loc_loctype)   {
+
+               case LOCMEMORY:
+               
+                       if (blob->loc_buffer != NULL)   {
+                               efree(blob->loc_buffer);
+                               blob->loc_buffer = NULL;
+                       }
+
+                       break;
+
+               case LOCFNAME:
+
+                       if (blob->loc_fd >= 0)   {
+                               close(blob->loc_fd);
+                       }
+                       blob->loc_fd = -1;
+
+                       if (blob->loc_fname != NULL)   {
+                               unlink(blob->loc_fname);
+                               efree(blob->loc_fname);
+                               blob->loc_fname = NULL;
+                       }
+
+                       break;
+                       
+               case LOCFILE:
+               case LOCUSER:
+               default:
+                       break;
+
+
+       }
+
 }
+               
+
 
 /* ----------------------------------------------------------------------
 ** int ifx_copy_blob(int bid)
@@ -2913,15 +3184,15 @@ static long php_intifx_create_blob(long type, long mode, char* param, long len,
    Duplicates the given blob-object */
 PHP_FUNCTION(ifx_copy_blob) 
 {
-       zval *pbid;
+       zval **pbid;
        long newid;
   
-       if (ZEND_NUM_ARGS()!=1 || getParameters(ht, 1, &pbid)==FAILURE) {
+       if (ZEND_NUM_ARGS()!=1 || zend_get_parameters_ex(1, &pbid)==FAILURE) {
                WRONG_PARAM_COUNT;
        }
-       convert_to_long(pbid);
+       convert_to_long_ex(pbid);
 
-       newid=php_intifx_copy_blob(Z_LVAL_P(pbid),&EG(regular_list) TSRMLS_CC); 
+       newid=php_intifx_copy_blob(Z_LVAL_PP(pbid),&EG(regular_list) TSRMLS_CC); 
        if(newid<0) {
                RETURN_FALSE;
        } 
@@ -2933,7 +3204,7 @@ PHP_FUNCTION(ifx_copy_blob)
  * internal function
  * long php_intifx_copy_blob(long bid, HashTable *list)
  *
- * duplicates the given blob-object
+ * duplicates the given blob-object in the PHP resource list
  *  bid: Id of Blobobject
  *  list: internal hashlist of php
  * 
@@ -2948,13 +3219,13 @@ static long php_intifx_copy_blob(long bid, HashTable *list TSRMLS_DC)
 
        Ifx_blob_orig = (IFX_IDRES *) zend_list_find(bid,&type);
        if (type!=le_idresult || !(Ifx_blob_orig->type==TYPE_BLBYTE || Ifx_blob_orig->type==TYPE_BLTEXT)) {
-               php_error(E_WARNING,"%s(): %d is not a Informix blob-result index", get_active_function_name(TSRMLS_C), bid);
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "%d is not a Informix blob-result index", bid);
                return -1;
        }
 
        Ifx_blob=emalloc(sizeof(IFX_IDRES));
        if(Ifx_blob==NULL) {
-               php_error(E_WARNING,"%s(): Can't create blob-resource", get_active_function_name(TSRMLS_C));
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can't create blob-resource");
                return -1;
        }
        
@@ -2966,39 +3237,31 @@ static long php_intifx_copy_blob(long bid, HashTable *list TSRMLS_DC)
        locator=&(Ifx_blob->BLOB.blob_data);
        locator_orig=&(Ifx_blob_orig->BLOB.blob_data);
 
+       if (php_intifx_init_blob(locator, Ifx_blob->BLOB.mode, 1) < 0)   {
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can't create blob-resource");
+               return -1;
+       }
+
        if(Ifx_blob->BLOB.mode==BLMODE_INMEM) {
                char *content;
-               if(locator_orig->loc_size>=0 && locator_orig->loc_buffer!=NULL) {
+               if(locator_orig->loc_bufsize>=0 && locator_orig->loc_buffer!=NULL) {
                        if((content=emalloc(locator_orig->loc_size))==NULL) {
-                               php_error(E_WARNING,"%s(): Can't create blob-resource", get_active_function_name(TSRMLS_C));
+                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can't create blob-resource");
                                return -1;
                        }
-                       memcpy(content,locator_orig->loc_buffer,  locator_orig->loc_size);
+                       memcpy(content,locator_orig->loc_buffer,  locator_orig->loc_bufsize);
                        locator->loc_buffer=content;
-                       locator->loc_bufsize=locator_orig->loc_size;
+                       locator->loc_bufsize=locator_orig->loc_bufsize;
                        locator->loc_size=locator_orig->loc_size;
-               } else {
-                       locator->loc_buffer=NULL;
-                       locator->loc_bufsize=-1;
-                       locator->loc_size=-1;
                }
-               locator->loc_loctype=LOCMEMORY;
-               locator->loc_mflags=0;
-               locator->loc_oflags=0;
        } else {  /* BLMODE_INFILE */
-               char *filename;
                
-               if((filename=emalloc(strlen(locator_orig->loc_fname)+1))==NULL)  {
-                       php_error(E_WARNING, "%s(): Can't create blob-resource", get_active_function_name(TSRMLS_C));
-                       return -1;
+               if (locator_orig->loc_size)   {
+                       php_copy_file(locator_orig->loc_fname, locator->loc_fname TSRMLS_C);
                }
-
-               strcpy(filename,locator_orig->loc_fname);
-               locator->loc_loctype=LOCFNAME;
-               locator->loc_fname=filename;
-               locator->loc_size=-1;
-               locator->loc_oflags=locator_orig->loc_oflags;
+               
        }
+       
        return zend_list_insert(Ifx_blob,le_idresult);
 }
 
@@ -3015,15 +3278,15 @@ static long php_intifx_copy_blob(long bid, HashTable *list TSRMLS_DC)
    Deletes the blob-object */
 PHP_FUNCTION(ifx_free_blob) 
 {
-       zval *pid;
+       zval **pid;
        long ret;
   
-       if (ZEND_NUM_ARGS()!=1 || getParameters(ht, 1, &pid)==FAILURE) {
+       if (ZEND_NUM_ARGS() !=1 || zend_get_parameters_ex(1, &pid) == FAILURE) {
                WRONG_PARAM_COUNT;
        }
-       convert_to_long(pid);
+       convert_to_long_ex(pid);
 
-       ret=php_intifx_free_blob(pid->value.lval,&EG(regular_list) TSRMLS_CC); 
+       ret=php_intifx_free_blob(Z_LVAL_PP(pid),&EG(regular_list) TSRMLS_CC); 
        if(ret<0) {
                RETURN_FALSE;
        } 
@@ -3035,7 +3298,7 @@ PHP_FUNCTION(ifx_free_blob)
  * internal function
  * long php_intifx_free_blob(long bid, HashTable *list)
  *
- * deletes the blob-object
+ * deletes the blob-object from the PHP Resource List
  *  bid: Id of Blobobject
  *  list: internal hashlist of php
  * 
@@ -3050,65 +3313,17 @@ static long php_intifx_free_blob(long bid, HashTable *list TSRMLS_DC)
 
        Ifx_blob = (IFX_IDRES *) zend_list_find(bid,&type);
        if (type!=le_idresult && !(Ifx_blob->type==TYPE_BLTEXT || Ifx_blob->type==TYPE_BLBYTE)) {
-               php_error(E_WARNING, "%s(): %d is not a Informix blob-result index", get_active_function_name(TSRMLS_C), bid);
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "%d is not a Informix blob-result index", bid);
                return -1;
        }
 
-       if(Ifx_blob->BLOB.mode==BLMODE_INMEM) {
-               if(Ifx_blob->BLOB.blob_data.loc_buffer==NULL || Ifx_blob->BLOB.blob_data.loc_size<=0) {;} else {
-                       efree(Ifx_blob->BLOB.blob_data.loc_buffer);  
-               }
-       } else {   /* BLMODE_INFILE */
-               if(Ifx_blob->BLOB.blob_data.loc_fname!=NULL) {
-                       efree(Ifx_blob->BLOB.blob_data.loc_fname); 
-               }
-       }
-       zend_list_delete(bid);
-       efree(Ifx_blob); 
-       return 0;
-}
-
-/* ----------------------------------------------------------------------
- * internal function
- * long php_intifx2_free_blob(long bid, HashTable *list)
- *
- * deletes the blob-object
- *  bid: Id of Blobobject
- *  list: internal hashlist of php
- * 
- * return -1 on error otherwise 0
- * FREES BYTE-MEMORY WITH FREE(), for blob memory allocated by ESQL/C  
- * use this for freeing blob-source after select (in ifx_free_result)
- * ----------------------------------------------------------------------
-*/
-static long php_intifx2_free_blob(long bid, HashTable *list TSRMLS_DC) 
-{
-       IFX_IDRES *Ifx_blob; 
-       int type;
-
-       Ifx_blob = (IFX_IDRES *) zend_list_find(bid,&type);
-       if (type!=le_idresult && !(Ifx_blob->type==TYPE_BLTEXT || Ifx_blob->type==TYPE_BLBYTE)) {
-               php_error(E_WARNING, "%s(): %d is not a Informix blob-result index", get_active_function_name(TSRMLS_C), bid);
+       if (!(Ifx_blob->type==TYPE_BLTEXT || Ifx_blob->type==TYPE_BLBYTE)) {
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "%d is not a Informix BYTE or TEXT type", bid);
                return -1;
        }
 
-#if IFX_VERSION < 724 /* this Informix  memory leak is fixed from 7.24 on     */
-                      /* according to the current PERL DBD::Informix          */
-                      /* and otherwise I get segmenation violations with 7.30 */
-
-       if(Ifx_blob->BLOB.mode==BLMODE_INMEM) {
-               if(Ifx_blob->BLOB.blob_data.loc_buffer==NULL || Ifx_blob->BLOB.blob_data.loc_size<=0) {;} else {
-                       free(Ifx_blob->BLOB.blob_data.loc_buffer);  
-               }
-       } else {
-               if(Ifx_blob->BLOB.blob_data.loc_fname!=NULL) {
-                       efree(Ifx_blob->BLOB.blob_data.loc_fname); 
-               }
-       }
-#endif
-  
        zend_list_delete(bid);
-       efree(Ifx_blob); 
+
        return 0;
 }
 
@@ -3125,16 +3340,16 @@ static long php_intifx2_free_blob(long bid, HashTable *list TSRMLS_DC)
    Returns the content of the blob-object */
 PHP_FUNCTION(ifx_get_blob) 
 {
-       zval *pbid;
+       zval **pbid;
        char *content;
        long len;
   
-       if (ZEND_NUM_ARGS()!=1 || getParameters(ht, 1, &pbid)==FAILURE) {
+       if (ZEND_NUM_ARGS() !=1 || zend_get_parameters_ex(1, &pbid) == FAILURE) {
                WRONG_PARAM_COUNT;
        }
-       convert_to_long(pbid);
+       convert_to_long_ex(pbid);
 
-       len=php_intifx_get_blob(pbid->value.lval,&EG(regular_list),&content TSRMLS_CC); 
+       len=php_intifx_get_blob(Z_LVAL_PP(pbid),&EG(regular_list),&content TSRMLS_CC); 
        if(content==NULL || len<0) {
                RETURN_STRING(php_intifx_null(TSRMLS_C),1);
        }
@@ -3161,7 +3376,7 @@ static long php_intifx_get_blob(long bid, HashTable *list, char** content TSRMLS
 
        Ifx_blob = (IFX_IDRES *) zend_list_find(bid,&type);
        if (type!=le_idresult && !(Ifx_blob->type==TYPE_BLTEXT || Ifx_blob->type==TYPE_BLBYTE)) {
-               php_error(E_WARNING, "%s(): %d is not a Informix blob-result index", get_active_function_name(TSRMLS_C), bid);
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "%d is not a Informix blob-result index", bid);
                return -1;
        }
 
@@ -3190,7 +3405,7 @@ static loc_t *php_intifx_get_blobloc(long bid, HashTable *list TSRMLS_DC)
 
        Ifx_blob = (IFX_IDRES *) zend_list_find(bid,&type);
        if (type!=le_idresult && !(Ifx_blob->type==TYPE_BLTEXT || Ifx_blob->type==TYPE_BLBYTE)) {
-               php_error(E_WARNING, "%s(): %d is not a Informix blob-result index", get_active_function_name(TSRMLS_C), bid);
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "%d is not a Informix blob-result index", bid);
                return NULL;
        }
        return &(Ifx_blob->BLOB.blob_data);
@@ -3212,15 +3427,15 @@ static loc_t *php_intifx_get_blobloc(long bid, HashTable *list TSRMLS_DC)
    Updates the content of the blob-object */
 PHP_FUNCTION(ifx_update_blob) 
 {
-       zval *pbid, *pparam;
+       zval **pbid, **pparam;
   
-       if (ZEND_NUM_ARGS()!=2 || getParameters(ht, 2, &pbid,&pparam)==FAILURE) {
+       if (ZEND_NUM_ARGS() !=2 || zend_get_parameters_ex(2, &pbid,&pparam) == FAILURE) {
                WRONG_PARAM_COUNT;
        }
-       convert_to_long(pbid);
-       convert_to_string(pparam);
+       convert_to_long_ex(pbid);
+       convert_to_string_ex(pparam);
 
-       if(php_intifx_update_blob(Z_LVAL_P(pbid),Z_STRVAL_P(pparam),Z_STRLEN_P(pparam), &EG(regular_list) TSRMLS_CC) < 0) { 
+       if(php_intifx_update_blob(Z_LVAL_PP(pbid),Z_STRVAL_PP(pparam),Z_STRLEN_PP(pparam), &EG(regular_list) TSRMLS_CC) < 0) { 
                RETURN_FALSE;
        } 
        RETURN_TRUE;
@@ -3246,7 +3461,7 @@ static long php_intifx_update_blob(long bid, char* param, long len, HashTable *l
 
        Ifx_blob = (IFX_IDRES *) zend_list_find(bid,&type);
        if (type!=le_idresult && !(Ifx_blob->type==TYPE_BLTEXT || Ifx_blob->type==TYPE_BLBYTE)) {
-               php_error(E_WARNING,"%s(): %d is not a Informix blob-result index", get_active_function_name(TSRMLS_C), bid);
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "%d is not a Informix blob-result index", bid);
                return -1;
        }
 
@@ -3258,7 +3473,7 @@ static long php_intifx_update_blob(long bid, char* param, long len, HashTable *l
                }
                if(len >= 0) {
                        if((content=emalloc(len))==NULL) {
-                               php_error(E_WARNING, "%s(): Can't create blob-resource", get_active_function_name(TSRMLS_C));
+                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can't create blob-resource");
                                return -1;
                        }
                        memcpy(content,param, len);
@@ -3279,7 +3494,7 @@ static long php_intifx_update_blob(long bid, char* param, long len, HashTable *l
                        efree(Ifx_blob->BLOB.blob_data.loc_fname);
                }
                if((filename=emalloc(len+1))==NULL)  {
-                       php_error(E_WARNING, "%s(): Can't create blob-resource", get_active_function_name(TSRMLS_C));
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can't create blob-resource");
                        return -1;
                }
                memcpy(filename,param, len);
@@ -3293,11 +3508,11 @@ static long php_intifx_update_blob(long bid, char* param, long len, HashTable *l
 /*-------------------------------------------------
  * internal function
  *
- * php_intifx_create_tmpfile(long bid TSRMLS_DC)
+ * php_intifx_create_tmpfile(TSRMLS_DC)
  * creates a temporary file to store a blob in 
  *-------------------------------------------------
 */
-static char* php_intifx_create_tmpfile(long bid TSRMLS_DC) 
+static char* php_intifx_create_tmpfile(TSRMLS_DC) 
 {
        char filename[10];
        char *blobdir;
@@ -3308,17 +3523,158 @@ static char* php_intifx_create_tmpfile(long bid TSRMLS_DC)
        if ((blobdir = getenv("php_blobdir")) == NULL) {
                blobdir=".";
        }
-       sprintf(filename,"blb%d",(int)bid);
+       sprintf(filename,"blb");
 
        if ((fp = php_open_temporary_file(blobdir, filename, &opened_path TSRMLS_CC))) {
                fclose(fp);
                retval=estrndup(opened_path, strlen(opened_path));
+               efree(opened_path);
        } else {
                retval=NULL;
        }
        return retval;
 }
 
+/* ----------------------------------------------------------------------
+ * int php_intifx_alloc_ibind(IFX_RES *Ifx_Result, int items TSRMLS_DC)
+ *
+ * Allocates descriptors for input parameters
+ * return 0 for error. 1 for ok
+ * ----------------------------------------------------------------------
+*/
+
+static long php_intifx_alloc_ibind(IFX_RES *Ifx_Result, int items TSRMLS_DC)   {
+
+       EXEC SQL BEGIN DECLARE SECTION;
+               char *i_bind = Ifx_Result->i_descrpid;
+               int bind_size = items;
+       EXEC SQL END DECLARE SECTION;
+       
+       if (items > Ifx_Result->numicols)   {
+                      
+               if (Ifx_Result->numicols > 0)   {
+                       EXEC SQL DEALLOCATE DESCRIPTOR :i_bind;
+                       if (ifx_check() < 0)   {
+                               return 0;
+                       }
+               }
+       
+               EXEC SQL ALLOCATE DESCRIPTOR :i_bind WITH MAX :bind_size;
+               if (ifx_check() < 0)   {
+                       return 0;
+               }
+       
+               Ifx_Result->numicols = items;
+       }
+       
+       return 1;
+       
+}
+
+/* ----------------------------------------------------------------------
+ * int php_intifx_preparse(char *statement TSRMLS_DC)
+ *
+ * Count the placeholders (?) parameters in the statement
+ * return -1 for error. 0 or number of question marks
+ *
+ * Thanks to DBD-Informix
+ *
+ * ----------------------------------------------------------------------
+*/
+static long php_intifx_preparse(char *statement TSRMLS_DC)   {
+
+       
+       char            end_quote = '\0';
+       char           *src;
+       char           *dst;
+       int             idx = 0;
+       int             style = 0;
+       int             laststyle = 0;
+       char            ch;
+
+       src = statement;
+       dst = statement;
+       while ((ch = *src++) != '\0') {
+
+               if (ch == end_quote)
+                       end_quote = '\0';
+               else if (end_quote != '\0') {
+                       *dst++ = ch;
+                       continue;
+               }
+
+               else if (ch == '\'' || ch == '\"')
+                       end_quote = ch;
+               else if (ch == '{')
+                       end_quote = '}';
+               else if (ch == '-' && *src == '-') {
+                       end_quote = '\n';
+               }
+
+               if (ch == '?') {
+                       /* X/Open standard       */
+                       *dst++ = '?';
+                       idx++;
+                       style = 3;
+               } else {
+                       /* Perhaps ':=' PL/SQL construct or dbase:table in Informix */
+                       /* Or it could be :2 or :22 as part of a DATETIME/INTERVAL */
+                       *dst++ = ch;
+                       continue;
+               }
+
+               if (laststyle && style != laststyle)
+                       return -1;
+
+               laststyle = style;
+       }
+
+       *dst = '\0';
+       return(idx);
+
+}
+
+/* ----------------------------------------------------------------------
+ * int php_intifx_count_descriptors(char *p_statemid TSRMLS_DC)
+ *
+ * count the number of descriptors allocated for a certain statement
+ * return 384 or number of descriptors
+ * ----------------------------------------------------------------------
+*/
+static long php_intifx_count_descriptors(char *p_statemid TSRMLS_DC)   {
+       
+       EXEC SQL BEGIN DECLARE SECTION;
+       char *statemid = p_statemid;
+       EXEC SQL END DECLARE SECTION;
+
+       struct sqlda *s_da;
+       int ret = 384;
+
+       EXEC SQL DESCRIBE :statemid INTO s_da;
+
+       if (ifx_check() >= 0)   {
+
+               ret = s_da->sqld;
+               
+               /*
+                * Thanks to DBD-Informix
+                */
+
+#if (ESQLC_VERSION >= 720 || (ESQLC_VERSION >= 501 && ESQLC_VERSION < 600))
+                       SqlFreeMem(s_da, SQLDA_FREE);
+               else
+                       free(s_da);
+#endif
+       }
+
+       return ret;
+
+}
+
+
+
+
+
 /* ----------------------------------------------------------------------
 ** void ifx_blobinfile_mode(int mode)
 **
@@ -3333,14 +3689,14 @@ static char* php_intifx_create_tmpfile(long bid TSRMLS_DC)
    Sets the default blob-mode for all select-queries  */
 PHP_FUNCTION(ifx_blobinfile_mode) 
 {
-       zval *pmode;
+       zval **pmode;
 
-       if (ZEND_NUM_ARGS()!=1 || getParameters(ht, 1, &pmode)==FAILURE) {
+       if (ZEND_NUM_ARGS() !=1 || zend_get_parameters_ex(1, &pmode) == FAILURE) {
                WRONG_PARAM_COUNT;
        }
-       convert_to_long(pmode);
+       convert_to_long_ex(pmode);
 
-       IFXG(blobinfile)=Z_LVAL_P(pmode);
+       IFXG(blobinfile)=Z_LVAL_PP(pmode);
        RETURN_TRUE;
 }
 /* }}} */
@@ -3359,14 +3715,14 @@ PHP_FUNCTION(ifx_blobinfile_mode)
    Sets the default text-mode for all select-queries */
 PHP_FUNCTION(ifx_textasvarchar) 
 {
-       zval *pmode;
+       zval **pmode;
        
-       if (ZEND_NUM_ARGS()!=1 || getParameters(ht, 1, &pmode)==FAILURE) {
+       if (ZEND_NUM_ARGS() !=1 || zend_get_parameters_ex(1, &pmode) == FAILURE) {
                WRONG_PARAM_COUNT;
        }
-       convert_to_long(pmode);
+       convert_to_long_ex(pmode);
 
-       IFXG(textasvarchar)=Z_LVAL_P(pmode);
+       IFXG(textasvarchar)=Z_LVAL_PP(pmode);
        RETURN_TRUE;
 }
 /* }}} */
@@ -3385,14 +3741,14 @@ PHP_FUNCTION(ifx_textasvarchar)
    Sets the default byte-mode for all select-queries  */
 PHP_FUNCTION(ifx_byteasvarchar) 
 {
-       zval *pmode;
+       zval **pmode;
 
-       if (ZEND_NUM_ARGS()!=1 || getParameters(ht, 1, &pmode)==FAILURE) {
+       if (ZEND_NUM_ARGS() !=1 || zend_get_parameters_ex(1, &pmode) == FAILURE) {
                WRONG_PARAM_COUNT;
        }
-       convert_to_long(pmode);
+       convert_to_long_ex(pmode);
 
-       IFXG(byteasvarchar)=Z_LVAL_P(pmode);
+       IFXG(byteasvarchar)=Z_LVAL_PP(pmode);
        RETURN_TRUE;
 }
 
@@ -3410,14 +3766,14 @@ PHP_FUNCTION(ifx_byteasvarchar)
    Sets the default return value of a NULL-value on a fetch-row  */
 PHP_FUNCTION(ifx_nullformat)
 {
-       zval *pmode;
+       zval **pmode;
        
-       if (ZEND_NUM_ARGS()!=1 || getParameters(ht, 1, &pmode)==FAILURE) {
+       if (ZEND_NUM_ARGS() !=1 || zend_get_parameters_ex(1, &pmode) == FAILURE) {
                WRONG_PARAM_COUNT;
        }
-       convert_to_long(pmode);
+       convert_to_long_ex(pmode);
 
-       IFXG(nullformat)=Z_LVAL_P(pmode);
+       IFXG(nullformat)=Z_LVAL_PP(pmode);
        RETURN_TRUE;
 }
 /* }}} */
@@ -3455,15 +3811,15 @@ static char* php_intifx_null(TSRMLS_D)
    Creates a char-object */
 PHP_FUNCTION(ifx_create_char)
 {
-       zval *pparam;
+       zval **pparam;
        long id;
   
-       if (ZEND_NUM_ARGS()!=1 || getParameters(ht, 1, &pparam)==FAILURE) {
+       if (ZEND_NUM_ARGS() !=1 || zend_get_parameters_ex(1, &pparam) == FAILURE) {
                WRONG_PARAM_COUNT;
        }
-       convert_to_string(pparam);
+       convert_to_string_ex(pparam);
 
-       id=php_intifx_create_char(Z_STRVAL_P(pparam),Z_STRLEN_P(pparam),&EG(regular_list) TSRMLS_CC); 
+       id=php_intifx_create_char(Z_STRVAL_PP(pparam),Z_STRLEN_PP(pparam),&EG(regular_list) TSRMLS_CC); 
        
        if(id < 0) {
                RETURN_FALSE;
@@ -3489,7 +3845,7 @@ static long php_intifx_create_char(char* param, long len, HashTable *list TSRMLS
 
        Ifx_char=emalloc(sizeof(IFX_IDRES));
        if(Ifx_char==NULL) {
-               php_error(E_WARNING, "%s(): Can't create char-resource", get_active_function_name(TSRMLS_C));
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can't create char-resource");
                return -1;
        }
 
@@ -3502,7 +3858,7 @@ static long php_intifx_create_char(char* param, long len, HashTable *list TSRMLS
                Ifx_char->CHAR.char_data=emalloc(len+1);
                if(Ifx_char->CHAR.char_data==NULL) {
                        efree(Ifx_char);
-                       php_error(E_WARNING, "%s(): Can't create char-resource", get_active_function_name(TSRMLS_C));
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can't create char-resource");
                        return -1;
                }
                memcpy(Ifx_char->CHAR.char_data,param,len);
@@ -3525,16 +3881,16 @@ static long php_intifx_create_char(char* param, long len, HashTable *list TSRMLS
    Returns the content of the char-object */
 PHP_FUNCTION(ifx_get_char) 
 {
-       zval *pbid;
+       zval **pbid;
        char *content;
        long len;
 
-       if (ZEND_NUM_ARGS()!=1 || getParameters(ht, 1, &pbid)==FAILURE) {
+       if (ZEND_NUM_ARGS() !=1 || zend_get_parameters_ex(1, &pbid) == FAILURE) {
                WRONG_PARAM_COUNT;
        }
-       convert_to_long(pbid);
+       convert_to_long_ex(pbid);
 
-       len=php_intifx_get_char(Z_LVAL_P(pbid),&EG(regular_list),&content TSRMLS_CC); 
+       len=php_intifx_get_char(Z_LVAL_PP(pbid),&EG(regular_list),&content TSRMLS_CC); 
        if(content==NULL || len < 0) {
                RETURN_STRING("",1);
        }
@@ -3561,7 +3917,7 @@ static long php_intifx_get_char(long bid, HashTable *list, char** content TSRMLS
 
        Ifx_char = (IFX_IDRES *) zend_list_find(bid,&type);
        if (type!=le_idresult && !(Ifx_char->type==TYPE_CHAR)) {
-               php_error(E_WARNING, "%s(): %d is not a Informix char-result index", get_active_function_name(TSRMLS_C), bid);
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "%d is not a Informix char-result index", bid);
                return -1;
        }
 
@@ -3582,14 +3938,14 @@ static long php_intifx_get_char(long bid, HashTable *list, char** content TSRMLS
    Deletes the char-object */
 PHP_FUNCTION(ifx_free_char) 
 {
-       zval *pid;
+       zval **pid;
   
-       if (ZEND_NUM_ARGS()!=1 || getParameters(ht, 1, &pid)==FAILURE) {
+       if (ZEND_NUM_ARGS() !=1 || zend_get_parameters_ex(1, &pid) == FAILURE) {
                WRONG_PARAM_COUNT;
        }
-       convert_to_long(pid);
+       convert_to_long_ex(pid);
 
-       if(php_intifx_free_char(Z_LVAL_P(pid),&EG(regular_list) TSRMLS_CC) < 0) {
+       if(php_intifx_free_char(Z_LVAL_PP(pid),&EG(regular_list) TSRMLS_CC) < 0) {
                RETURN_FALSE;
        }
        RETURN_TRUE;
@@ -3614,7 +3970,7 @@ static long php_intifx_free_char(long bid, HashTable *list TSRMLS_DC)
 
        Ifx_char = (IFX_IDRES *) zend_list_find(bid,&type);
        if (type!=le_idresult && !(Ifx_char->type==TYPE_CHAR)) {
-               php_error(E_WARNING, "%s(): %d is not a Informix char-result index", get_active_function_name(TSRMLS_C), bid);
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "%d is not a Informix char-result index", bid);
                return -1;
        }
 
@@ -3640,15 +3996,15 @@ static long php_intifx_free_char(long bid, HashTable *list TSRMLS_DC)
    Updates the content of the char-object */
 PHP_FUNCTION(ifx_update_char)
 {
-       zval *pbid,*pparam;
+       zval **pbid, **pparam;
   
-       if (ZEND_NUM_ARGS()!=2 || getParameters(ht, 2, &pbid,&pparam)==FAILURE) {
+       if (ZEND_NUM_ARGS()!=2 || zend_get_parameters_ex(2, &pbid,&pparam) == FAILURE) {
                WRONG_PARAM_COUNT;
        }
-       convert_to_long(pbid);
-       convert_to_string(pparam);
+       convert_to_long_ex(pbid);
+       convert_to_string_ex(pparam);
  
-       if(php_intifx_update_char(Z_LVAL_P(pbid),Z_STRVAL_P(pparam),Z_STRLEN_P(pparam),&EG(regular_list) TSRMLS_CC) < 0) {
+       if(php_intifx_update_char(Z_LVAL_PP(pbid),Z_STRVAL_PP(pparam),Z_STRLEN_PP(pparam),&EG(regular_list) TSRMLS_CC) < 0) {
                RETURN_FALSE;
        }
        RETURN_TRUE;
@@ -3674,7 +4030,7 @@ static long php_intifx_update_char(long bid, char* param, long len, HashTable *l
 
        Ifx_char = (IFX_IDRES *) zend_list_find(bid,&type);
        if (type!=le_idresult && !(Ifx_char->type==TYPE_CHAR)) {
-               php_error(E_WARNING, "%s(): %d is not a Informix char-result index", get_active_function_name(TSRMLS_C), bid);
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "%d is not a Informix char-result index", bid);
                return -1;
        }
 
@@ -3690,7 +4046,7 @@ static long php_intifx_update_char(long bid, char* param, long len, HashTable *l
        } else {
                Ifx_char->CHAR.char_data=emalloc(len+1);
                if(Ifx_char->CHAR.char_data==NULL) {
-                       php_error(E_WARNING, "%s(): Can't create char-resource", get_active_function_name(TSRMLS_C));
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can't create char-resource");
                        return -1;
                }
                memcpy(Ifx_char->CHAR.char_data,param,len);
@@ -3715,15 +4071,15 @@ $ifdef HAVE_IFX_IUS;
    Creates a slob-object and opens it */
 PHP_FUNCTION(ifxus_create_slob)
 {
-       zval *pmode;
+       zval **pmode;
        long id;
        long mode,create_mode;
   
-       if (ZEND_NUM_ARGS()!=1 || getParameters(ht, 1, &pmode)==FAILURE) {
+       if (ZEND_NUM_ARGS()!=1 || zend_get_parameters_ex(1, &pmode)==FAILURE) {
                WRONG_PARAM_COUNT;
        }
-       convert_to_long(pmode);
-       mode=Z_LVAL_P(pmode);
+       convert_to_long_ex(pmode);
+       mode=Z_LVAL_PP(pmode);
  
        create_mode=0;
        if((mode&1) !=0)   
@@ -3765,20 +4121,20 @@ static long php_intifxus_create_slob(long create_mode, HashTable *list TSRMLS_DC
        
        Ifx_slob=emalloc(sizeof(IFX_IDRES));
        if(Ifx_slob==NULL) {
-               php_error(E_WARNING, "%s(): Can't create slob-resource", get_active_function_name(TSRMLS_C));
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can't create slob-resource");
                return -1;
        }
 
        errcode=ifx_lo_def_create_spec(&(Ifx_slob->SLOB.createspec));
        if(errcode<0) {
-               php_error(E_WARNING, "%s(): Can't create slob-resource: %d", get_active_function_name(TSRMLS_C), errcode);
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can't create slob-resource: %d", errcode);
                return -1;
        }
 
        Ifx_slob->type=TYPE_SLOB;
        Ifx_slob->SLOB.lofd=ifx_lo_create(Ifx_slob->SLOB.createspec,create_mode,&(Ifx_slob->SLOB.slob_data),&errcode);
        if(errcode<0 || Ifx_slob->SLOB.lofd<0) {
-               php_error(E_WARNING, "%s(): Can't create slob-resource: %d", get_active_function_name(TSRMLS_C), errcode);
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can't create slob-resource: %d", errcode);
                return -1;
        }
        return zend_list_insert(Ifx_slob,le_idresult);
@@ -3797,14 +4153,14 @@ static long php_intifxus_create_slob(long create_mode, HashTable *list TSRMLS_DC
    Deletes the slob-object */
 PHP_FUNCTION(ifxus_free_slob) 
 {
-       zval *pid;
+       zval **pid;
 
-       if (ZEND_NUM_ARGS()!=1 || getParameters(ht, 1, &pid)==FAILURE) {
+       if (ZEND_NUM_ARGS() !=1 || zend_get_parameters_ex(1, &pid) == FAILURE) {
                WRONG_PARAM_COUNT;
        }
-       convert_to_long(pid);
+       convert_to_long_ex(pid);
 
-       if(php_intifxus_free_slob(Z_LVAL_P(pid),&EG(regular_list) TSRMLS_CC) < 0) {
+       if(php_intifxus_free_slob(Z_LVAL_PP(pid),&EG(regular_list) TSRMLS_CC) < 0) {
                RETURN_FALSE;
        }
        RETURN_TRUE;
@@ -3829,7 +4185,7 @@ static long php_intifxus_free_slob(long bid, HashTable *list TSRMLS_DC)
        
        Ifx_slob = (IFX_IDRES *) zend_list_find(bid,&type);
        if (type!=le_idresult || Ifx_slob->type!=TYPE_SLOB) {
-               php_error(E_WARNING, "%s(): %d is not a Informix slob-result index", get_active_function_name(TSRMLS_C), bid);
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "%d is not a Informix slob-result index", bid);
                return -1;
        }
        
@@ -3859,13 +4215,13 @@ static long php_intifxus_free_slob(long bid, HashTable *list TSRMLS_DC)
    Deletes the slob-object */
 PHP_FUNCTION(ifxus_close_slob)
 {
-       zval *pid;
+       zval **pid;
        
-       if (ZEND_NUM_ARGS()!=1 || getParameters(ht, 1, &pid)==FAILURE) {
+       if (ZEND_NUM_ARGS()!=1 || zend_get_parameters_ex(1, &pid) == FAILURE) {
                WRONG_PARAM_COUNT;
        }
-       convert_to_long(pid);
-       if(php_intifxus_close_slob(Z_LVAL_P(pid),&EG(regular_list) TSRMLS_CC) < 0) {
+       convert_to_long_ex(pid);
+       if(php_intifxus_close_slob(Z_LVAL_PP(pid),&EG(regular_list) TSRMLS_CC) < 0) {
                RETURN_FALSE;
        }
        RETURN_TRUE;
@@ -3890,17 +4246,17 @@ static long php_intifxus_close_slob(long bid, HashTable *list TSRMLS_DC)
 
        Ifx_slob = (IFX_IDRES *) zend_list_find(bid,&type);
        if (type!=le_idresult || Ifx_slob->type!=TYPE_SLOB) {
-               php_error(E_WARNING, "%s(): %d is not a Informix slob-result index", get_active_function_name(TSRMLS_C), bid);
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "%d is not a Informix slob-result index", bid);
                return -1;
        }
        
        if(Ifx_slob->SLOB.lofd<0) {
-               php_error(E_WARNING, "%s(): Slob-resource already closed", get_active_function_name(TSRMLS_C));
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Slob-resource already closed");
                return -1;
        }
 
        if(ifx_lo_close(Ifx_slob->SLOB.lofd)<0) {
-               php_error(E_WARNING, "%s(): Can't close slob-resource", get_active_function_name(TSRMLS_C));
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can't close slob-resource");
                return -1;
        }
        Ifx_slob->SLOB.lofd=-1;
@@ -3921,15 +4277,15 @@ static long php_intifxus_close_slob(long bid, HashTable *list TSRMLS_DC)
    Opens an slob-object */
 PHP_FUNCTION(ifxus_open_slob)
 {
-       zval *pbid,*pmode;
+       zval **pbid, **pmode;
        long mode,create_mode;
          
-       if (ZEND_NUM_ARGS()!=2 || getParameters(ht, 1, &pbid,&pmode)==FAILURE) {
+       if (ZEND_NUM_ARGS()!=2 || zend_get_parameters_ex(1, &pbid, &pmode) == FAILURE) {
                WRONG_PARAM_COUNT;
        }
-       convert_to_long(pmode);
-       convert_to_long(pbid);
-       mode=Z_LVAL_P(pmode);
+       convert_to_long_ex(pmode);
+       convert_to_long_ex(pbid);
+       mode=Z_LVAL_PP(pmode);
 
        create_mode=0;
        if((mode&1) !=0)   
@@ -3945,7 +4301,7 @@ PHP_FUNCTION(ifxus_open_slob)
        if((mode&32) !=0)   
                create_mode|=LO_NOBUFFER;
 
-       RETURN_LONG(php_intifxus_open_slob(Z_LVAL_P(pbid),create_mode,&EG(regular_list) TSRMLS_CC));
+       RETURN_LONG(php_intifxus_open_slob(Z_LVAL_PP(pbid),create_mode,&EG(regular_list) TSRMLS_CC));
 }
 /* }}} */
 
@@ -3968,18 +4324,18 @@ static long php_intifxus_open_slob(long bid, long create_mode, HashTable *list T
 
        Ifx_slob = (IFX_IDRES *) zend_list_find(bid,&type);
        if (type!=le_idresult || Ifx_slob->type!=TYPE_SLOB) {
-               php_error(E_WARNING, "%s(): %d is not a Informix slob-result index", get_active_function_name(TSRMLS_C), bid);
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "%d is not a Informix slob-result index", bid);
                return -1;
        }
 
        if(Ifx_slob->SLOB.lofd>0) {
-               php_error(E_WARNING, "%s(): Slob-resource already open", get_active_function_name(TSRMLS_C));
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Slob-resource already open");
                return -1;
        }
 
        Ifx_slob->SLOB.lofd=ifx_lo_open(&(Ifx_slob->SLOB.slob_data),create_mode,&errcode);
        if(errcode < 0 || Ifx_slob->SLOB.lofd < 0) {
-               php_error(E_WARNING, "%s(): Can't open slob-resource: %d", get_active_function_name(TSRMLS_C), errcode);
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can't open slob-resource: %d", errcode);
                return -1;
        }
        return 0;
@@ -4000,7 +4356,7 @@ static long php_intifxus_new_slob(HashTable *list TSRMLS_DC)
 
        Ifx_slob=emalloc(sizeof(IFX_IDRES));
        if(Ifx_slob==NULL) {
-               php_error(E_WARNING, "%s(): Can't create slob-resource", get_active_function_name(TSRMLS_C));
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can't create slob-resource");
                return -1;
        }
        
@@ -4026,7 +4382,7 @@ static ifx_lo_t *php_intifxus_get_slobloc(long bid, HashTable *list TSRMLS_DC)
 
        Ifx_slob = (IFX_IDRES *) zend_list_find(bid,&type);
        if (type!=le_idresult  || Ifx_slob->type!=TYPE_SLOB) {
-               php_error(E_WARNING, "%s(): %d is not a Informix slob-result index", get_active_function_name(TSRMLS_C), bid);
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "%d is not a Informix slob-result index", bid);
                return NULL;
        }
        return &(Ifx_slob->SLOB.slob_data);
@@ -4045,32 +4401,32 @@ static ifx_lo_t *php_intifxus_get_slobloc(long bid, HashTable *list TSRMLS_DC)
    Returns the current file or seek position of an open slob-object */
 PHP_FUNCTION(ifxus_tell_slob)
 {
-       zval *pbid;
+       zval **pbid;
        long bid;
        IFX_IDRES *Ifx_slob;
        ifx_int8_t akt_seek_pos;
        int type;
        long lakt_seek_pos;
 
-       if (ZEND_NUM_ARGS()!=1 || getParameters(ht, 1, &pbid)==FAILURE) {
+       if (ZEND_NUM_ARGS()!=1 || zend_get_parameters_ex(1, &pbid) == FAILURE) {
                WRONG_PARAM_COUNT;
        }
-       convert_to_long(pbid);
-       bid=Z_LVAL_P(pbid);
+       convert_to_long_ex(pbid);
+       bid=Z_LVAL_PP(pbid);
 
        Ifx_slob = (IFX_IDRES *) zend_list_find(bid,&type);
        if (type!=le_idresult || Ifx_slob->type!=TYPE_SLOB) {
-               php_error(E_WARNING,"%s(): %d is not a Informix slob-result index", get_active_function_name(TSRMLS_C), bid);
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "%d is not a Informix slob-result index", bid);
                RETURN_FALSE;
        }
 
        if(ifx_lo_tell(Ifx_slob->SLOB.lofd,&akt_seek_pos)<0) {
-               php_error(E_WARNING,"%s(): Can't perform tell-operation", get_active_function_name(TSRMLS_C));
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can't perform tell-operation");
                RETURN_FALSE;
        }
 
        if(ifx_int8tolong(&akt_seek_pos,&lakt_seek_pos)<0) {
-               php_error(E_WARNING, "%s(): Seek-position to large for long", get_active_function_name(TSRMLS_C));
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Seek-position to large for long");
                RETURN_FALSE;
        }
        RETURN_LONG(lakt_seek_pos);
@@ -4092,42 +4448,42 @@ PHP_FUNCTION(ifxus_tell_slob)
    Sets the current file or seek position of an open slob-object */
 PHP_FUNCTION(ifxus_seek_slob)
 {
-       zval *pbid, *pmode, *poffset;
+       zval **pbid, **pmode, **poffset;
        long bid,lakt_seek_pos;
        IFX_IDRES *Ifx_slob;
        ifx_int8_t akt_seek_pos,offset;
        int type,mode;
 
-       if (ZEND_NUM_ARGS()!=3 || getParameters(ht, 3, &pbid, &pmode, &poffset)==FAILURE) {
+       if (ZEND_NUM_ARGS() !=3 || zend_get_parameters_ex(3, &pbid, &pmode, &poffset) == FAILURE) {
                WRONG_PARAM_COUNT;
        }
-       convert_to_long(pbid);
-       convert_to_long(pmode); 
-       convert_to_long(poffset);
+       convert_to_long_ex(pbid);
+       convert_to_long_ex(pmode); 
+       convert_to_long_ex(poffset);
  
-       bid=Z_LVAL_P(pbid);
+       bid=Z_LVAL_PP(pbid);
        Ifx_slob = (IFX_IDRES *) zend_list_find(bid,&type);
        if (type!=le_idresult || Ifx_slob->type!=TYPE_SLOB) {
-               php_error(E_WARNING, "%s(): %d is not a Informix slob-result index", get_active_function_name(TSRMLS_C), bid);
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "%d is not a Informix slob-result index", bid);
                RETURN_FALSE;
        }
 
        mode=LO_SEEK_SET;
-       if(Z_LVAL_P(pmode)==1) {
+       if(Z_LVAL_PP(pmode)==1) {
                mode=LO_SEEK_CUR;
        }
-       if(Z_LVAL_P(pmode)==2) {
+       if(Z_LVAL_PP(pmode)==2) {
                mode=LO_SEEK_END;
        }
 
-       ifx_int8cvlong(Z_LVAL_P(poffset),&offset);
+       ifx_int8cvlong(Z_LVAL_PP(poffset),&offset);
        if(ifx_lo_seek(Ifx_slob->SLOB.lofd,&offset,mode,&akt_seek_pos)<0) {
-               php_error(E_WARNING, "%s(): Can't perform seek-operation", get_active_function_name(TSRMLS_C));
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can't perform seek-operation");
                RETURN_FALSE;
        }
 
        if(ifx_int8tolong(&akt_seek_pos,&lakt_seek_pos)<0) {
-               php_error(E_WARNING, "%s(): Seek-position to large for long", get_active_function_name(TSRMLS_C));
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Seek-position to large for long");
                RETURN_FALSE;
        }
        RETURN_LONG(lakt_seek_pos);
@@ -4148,30 +4504,30 @@ PHP_FUNCTION(ifxus_seek_slob)
    Reads nbytes of the slob-object */
 PHP_FUNCTION(ifxus_read_slob) 
 {
-       zval *pbid, *pnbytes;
+       zval **pbid, **pnbytes;
        long bid, nbytes;
        IFX_IDRES *Ifx_slob;
        int errcode,type;
        char *buffer;
 
-       if (ZEND_NUM_ARGS()!=2 || getParameters(ht, 2, &pbid, &pnbytes)==FAILURE) {
+       if (ZEND_NUM_ARGS()!=2 || zend_get_parameters_ex(2, &pbid, &pnbytes) == FAILURE) {
                WRONG_PARAM_COUNT;
        }
-       convert_to_long(pbid);
-       convert_to_long(pnbytes); 
+       convert_to_long_ex(pbid);
+       convert_to_long_ex(pnbytes); 
  
-       bid=Z_LVAL_P(pbid);
+       bid=Z_LVAL_PP(pbid);
        Ifx_slob = (IFX_IDRES *) zend_list_find(bid,&type);
        if (type!=le_idresult || Ifx_slob->type!=TYPE_SLOB) {
-               php_error(E_WARNING, "%s(): %d is not a Informix slob-result index", get_active_function_name(TSRMLS_C), bid);
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "%d is not a Informix slob-result index", bid);
                RETURN_FALSE;
        }
 
-       nbytes=Z_LVAL_P(pnbytes);
+       nbytes=Z_LVAL_PP(pnbytes);
        buffer=emalloc(nbytes);
        if(ifx_lo_read(Ifx_slob->SLOB.lofd,buffer,nbytes,&errcode)<0) {
                efree(buffer);
-               php_error(E_WARNING, "%s(): Error reading slob: %d", get_active_function_name(TSRMLS_C), errcode);
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error reading slob: %d", errcode);
                RETURN_FALSE;
        }
        RETURN_STRINGL(buffer,nbytes,0); 
@@ -4192,35 +4548,35 @@ PHP_FUNCTION(ifxus_read_slob)
    Writes a string into the slob-object */
 PHP_FUNCTION(ifxus_write_slob) 
 {
-       zval *pbid, *pcontent;
+       zval **pbid, **pcontent;
        long bid, nbytes;
        IFX_IDRES *Ifx_slob;
        int errcode,type;
        char *buffer;
 
-       if (ZEND_NUM_ARGS()!=2 || getParameters(ht, 2, &pbid, &pcontent)==FAILURE) {
+       if (ZEND_NUM_ARGS()!=2 || zend_get_parameters_ex(2, &pbid, &pcontent) == FAILURE) {
                WRONG_PARAM_COUNT;
        }
-       convert_to_long(pbid);
-       convert_to_string(pcontent); 
+       convert_to_long_ex(pbid);
+       convert_to_string_ex(pcontent); 
  
-       bid=Z_LVAL_P(pbid);
+       bid=Z_LVAL_PP(pbid);
        Ifx_slob = (IFX_IDRES *) zend_list_find(bid,&type);
        if (type!=le_idresult || Ifx_slob->type!=TYPE_SLOB) {
-               php_error(E_WARNING, "%s(): %d is not a Informix slob-result index", get_active_function_name(TSRMLS_C), bid);
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "%d is not a Informix slob-result index", bid);
                RETURN_FALSE;
        }
 
-       buffer=Z_STRVAL_P(pcontent);
-       nbytes=Z_STRLEN_P(pcontent);
+       buffer=Z_STRVAL_PP(pcontent);
+       nbytes=Z_STRLEN_PP(pcontent);
 
        if(nbytes<=0) {
-               php_error(E_WARNING, "%s(): String has no content", get_active_function_name(TSRMLS_C));
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "String has no content");
                RETURN_FALSE;
        }
 
        if((nbytes=ifx_lo_write(Ifx_slob->SLOB.lofd,buffer,nbytes,&errcode))<0) {
-               php_error(E_WARNING, "%s(): Error writing slob: %d", get_active_function_name(TSRMLS_C), errcode);
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error writing slob: %d", errcode);
                RETURN_FALSE;
        }
  
index 456ad57019b27e3b5ad54b7adde81428239c998b..fc0832bcc2a34b4e0fb85bfab893368348dbf310 100644 (file)
@@ -40,12 +40,14 @@ typedef struct ifx_res {
        char connecid[32];
        char cursorid[32];
        char descrpid[32];
+       char i_descrpid[32];
        char statemid[32];
        int  isscroll;
        int  ishold;
        int  iscursory;
        int  paramquery;
        int  numcols;
+       int  numicols;
        int  rowid;
        int  affected_rows;
        long sqlerrd[6];