From: Ard Biesheuvel Date: Wed, 5 May 2004 22:18:35 +0000 (+0000) Subject: Fixed unregistered bug: array count is incorrect when binding array ids X-Git-Tag: RELEASE_0_1~286 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=18d9462a227887add6b7e23d8174cc48dbfd39e4;p=php Fixed unregistered bug: array count is incorrect when binding array ids Fixed unregistered bug: empty numeric/datetime param argument is coerced to a string that cannot be handled by the IB API layer --- diff --git a/ext/interbase/ibase_query.c b/ext/interbase/ibase_query.c index e8436c03a4..9930040e2f 100644 --- a/ext/interbase/ibase_query.c +++ b/ext/interbase/ibase_query.c @@ -615,14 +615,7 @@ static int _php_ibase_bind(XSQLDA *sqlda, zval **b_vars, BIND_BUF *buf, /* {{{ * var->sqlind = &buf[i].sqlind; - if (Z_TYPE_P(b_var) == IS_NULL) { - if ((var->sqltype & 1) != 1) { - _php_ibase_module_error("Parameter %d must have a value" TSRMLS_CC, i+1); - rv = FAILURE; - } - buf[i].sqlind = -1; - if ((var->sqltype & ~1) == SQL_ARRAY) ++array_cnt; - } else { + if (Z_TYPE_P(b_var) != IS_NULL) { buf[i].sqlind = 0; if (var->sqlscale < 0) { @@ -630,7 +623,7 @@ static int _php_ibase_bind(XSQLDA *sqlda, zval **b_vars, BIND_BUF *buf, /* {{{ * DECIMAL or NUMERIC field are stored internally as scaled integers. Coerce it to string and let InterBase's internal routines handle it. */ - var->sqltype = SQL_TEXT; + goto php_ibase_bind_default; } var->sqldata = (void*)&buf[i]; @@ -775,7 +768,7 @@ static int _php_ibase_bind(XSQLDA *sqlda, zval **b_vars, BIND_BUF *buf, /* {{{ * } } else { /* convert the array data into something IB can understand */ - ibase_array *ar = &ib_query->in_array[array_cnt++]; + ibase_array *ar = &ib_query->in_array[array_cnt]; void *array_data = emalloc(ar->ar_size); ISC_QUAD array_id = { 0, 0 }; @@ -797,15 +790,32 @@ static int _php_ibase_bind(XSQLDA *sqlda, zval **b_vars, BIND_BUF *buf, /* {{{ * buf[i].val.qval = array_id; efree(array_data); } + ++array_cnt; break; - default: php_ibase_bind_default: + /* empty strings should be coerced to NULL for non-text types */ + if (Z_TYPE_P(b_var) == IS_STRING && Z_STRLEN_P(b_var) == 0) { + ZVAL_NULL(b_var); + break; + } + + default: convert_to_string(b_var); var->sqldata = Z_STRVAL_P(b_var); var->sqllen = Z_STRLEN_P(b_var); var->sqltype = SQL_TEXT; } /* switch */ } /* if */ + + if (Z_TYPE_P(b_var) == IS_NULL) { + if (! (var->sqltype & 1)) { + _php_ibase_module_error("Parameter %d must have a value" TSRMLS_CC, i+1); + rv = FAILURE; + } + buf[i].sqlind = -1; + + if (var->sqltype & SQL_ARRAY) ++array_cnt; + } } /* for */ return rv; }