diff options
| author | Ard Biesheuvel <abies@php.net> | 2004-05-05 22:18:35 +0000 |
|---|---|---|
| committer | Ard Biesheuvel <abies@php.net> | 2004-05-05 22:18:35 +0000 |
| commit | 18d9462a227887add6b7e23d8174cc48dbfd39e4 (patch) | |
| tree | d5095e928ce944f201eecc0a90404b8083012d8f /ext | |
| parent | 0180c36951d46810e76fd4f1a8eaa90d97a613a2 (diff) | |
| download | php-git-18d9462a227887add6b7e23d8174cc48dbfd39e4.tar.gz | |
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
Diffstat (limited to 'ext')
| -rw-r--r-- | ext/interbase/ibase_query.c | 32 |
1 files changed, 21 insertions, 11 deletions
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; } |
