summaryrefslogtreecommitdiff
path: root/ext/pdo_firebird/firebird_statement.c
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2017-01-06 18:12:52 +0100
committerAnatol Belski <ab@php.net>2017-01-06 18:12:52 +0100
commit847e1f97dab8afcac8d7eb71a75892a4e756583c (patch)
treefe1294355802ee5710b9a0e02ee7bdd8d0861852 /ext/pdo_firebird/firebird_statement.c
parentc50f61b9b06d65ed2391e7751a2adbdf8db91754 (diff)
parent826122fa8e1db4a0deee3830660ae3b8b5626534 (diff)
downloadphp-git-847e1f97dab8afcac8d7eb71a75892a4e756583c.tar.gz
Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0: Return integer field types as native integers instead of strings
Diffstat (limited to 'ext/pdo_firebird/firebird_statement.c')
-rw-r--r--ext/pdo_firebird/firebird_statement.c34
1 files changed, 29 insertions, 5 deletions
diff --git a/ext/pdo_firebird/firebird_statement.c b/ext/pdo_firebird/firebird_statement.c
index c83ba38db5..3feeedf39f 100644
--- a/ext/pdo_firebird/firebird_statement.c
+++ b/ext/pdo_firebird/firebird_statement.c
@@ -217,7 +217,23 @@ static int firebird_stmt_describe(pdo_stmt_t *stmt, int colno) /* {{{ */
}
memmove(cp, var->aliasname, var->aliasname_length);
*(cp+var->aliasname_length) = '\0';
- col->param_type = PDO_PARAM_STR;
+
+ if (var->sqlscale < 0) {
+ col->param_type = PDO_PARAM_STR;
+ } else {
+ switch (var->sqltype & ~1) {
+ case SQL_SHORT:
+ case SQL_LONG:
+#if SIZEOF_ZEND_LONG >= 8
+ case SQL_INT64:
+#endif
+ col->param_type = PDO_PARAM_INT;
+ break;
+ default:
+ col->param_type = PDO_PARAM_STR;
+ break;
+ }
+ }
return 1;
}
@@ -373,16 +389,24 @@ static int firebird_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, /* {{
*len = var->sqllen;
break;
case SQL_SHORT:
- *ptr = FETCH_BUF(S->fetch_buf[colno], char, CHAR_BUF_LEN, NULL);
- *len = slprintf(*ptr, CHAR_BUF_LEN, "%d", *(short*)var->sqldata);
+ *len = sizeof(zend_long);
+ *ptr = FETCH_BUF(S->fetch_buf[colno], zend_long, 1, NULL);
+ *(zend_long *)*ptr = *(short*)var->sqldata;
break;
case SQL_LONG:
- *ptr = FETCH_BUF(S->fetch_buf[colno], char, CHAR_BUF_LEN, NULL);
- *len = slprintf(*ptr, CHAR_BUF_LEN, "%d", *(ISC_LONG*)var->sqldata);
+ *len = sizeof(zend_long);
+ *ptr = FETCH_BUF(S->fetch_buf[colno], zend_long, 1, NULL);
+ *(zend_long *)*ptr = *(ISC_LONG*)var->sqldata;
break;
case SQL_INT64:
+#if SIZEOF_ZEND_LONG >= 8
+ *len = sizeof(zend_long);
+ *ptr = FETCH_BUF(S->fetch_buf[colno], zend_long, 1, NULL);
+ *(zend_long *)*ptr = *(ISC_INT64*)var->sqldata;
+#else
*ptr = FETCH_BUF(S->fetch_buf[colno], char, CHAR_BUF_LEN, NULL);
*len = slprintf(*ptr, CHAR_BUF_LEN, "%" LL_MASK "d", *(ISC_INT64*)var->sqldata);
+#endif
break;
case SQL_FLOAT:
*ptr = FETCH_BUF(S->fetch_buf[colno], char, CHAR_BUF_LEN, NULL);