diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c index 1ecd563eaf5..e480d5d17b0 100644 --- a/ext/mysqli/mysqli_api.c +++ b/ext/mysqli/mysqli_api.c @@ -705,10 +705,10 @@ PHP_FUNCTION(mysqli_stmt_fetch) #endif char tmp[22]; /* even though lval is declared as unsigned, the value - * may be negative. Therefor we cannot use %llu and must - * use %lld. + * may be negative. Therefor we cannot use MYSQLI_LLU_SPEC and must + * use MYSQLI_LL_SPEC. */ - sprintf((char *)&tmp, (stmt->stmt->fields[i].flags & UNSIGNED_FLAG)? "%llu":"%lld", llval); + sprintf((char *)&tmp, (stmt->stmt->fields[i].flags & UNSIGNED_FLAG)? MYSQLI_LLU_SPEC : MYSQLI_LL_SPEC, llval); ZVAL_STRING(stmt->result.vars[i], tmp, 1); } else { ZVAL_LONG(stmt->result.vars[i], llval); @@ -1859,7 +1859,7 @@ PHP_FUNCTION(mysqli_stmt_errno) if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_stmt, mysqli_stmt_class_entry) == FAILURE) { return; } - MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt", MYSQLI_STATUS_VALID); + MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt", MYSQLI_STATUS_INITIALIZED); RETURN_LONG(mysql_stmt_errno(stmt->stmt)); } @@ -1875,7 +1875,7 @@ PHP_FUNCTION(mysqli_stmt_error) if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_stmt, mysqli_stmt_class_entry) == FAILURE) { return; } - MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt", MYSQLI_STATUS_VALID); + MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt", MYSQLI_STATUS_INITIALIZED); RETURN_STRING((char *)mysql_stmt_error(stmt->stmt),1); } diff --git a/ext/mysqli/mysqli_prop.c b/ext/mysqli/mysqli_prop.c index 690a085c1be..db7b6377283 100644 --- a/ext/mysqli/mysqli_prop.c +++ b/ext/mysqli/mysqli_prop.c @@ -86,7 +86,7 @@ static int __func(mysqli_object *obj, zval **retval TSRMLS_DC) \ ZVAL_LONG(*retval, l);\ } else { \ char ret[40]; \ - sprintf(ret, "%llu", (my_ulonglong)l); \ + sprintf(ret, MYSQLI_LLU_SPEC, (my_ulonglong)l); \ ZVAL_STRING(*retval, ret, 1); \ } \ }\ @@ -176,7 +176,7 @@ static int link_affected_rows_read(mysqli_object *obj, zval **retval TSRMLS_DC) ZVAL_LONG(*retval, rc); } else { char ret[40]; - sprintf(ret, "%llu", (my_ulonglong) rc); + sprintf(ret, MYSQLI_LLU_SPEC, (my_ulonglong) rc); ZVAL_STRING(*retval, ret, 1); } } @@ -295,7 +295,7 @@ static int stmt_affected_rows_read(mysqli_object *obj, zval **retval TSRMLS_DC) ZVAL_LONG(*retval, rc); } else { char ret[40]; - sprintf(ret, "%llu", (my_ulonglong) rc); + sprintf(ret, MYSQLI_LLU_SPEC, (my_ulonglong) rc); ZVAL_STRING(*retval, ret, 1); } } diff --git a/ext/mysqli/php_mysqli.h b/ext/mysqli/php_mysqli.h index 79225b5cc71..8933010bc8a 100644 --- a/ext/mysqli/php_mysqli.h +++ b/ext/mysqli/php_mysqli.h @@ -118,8 +118,12 @@ typedef struct { #ifdef PHP_WIN32 #define PHP_MYSQLI_API __declspec(dllexport) +#define MYSQLI_LLU_SPEC "%I64u" +#define MYSQLI_LL_SPEC "%I64d" #else #define PHP_MYSQLI_API +#define MYSQLI_LLU_SPEC "%llu" +#define MYSQLI_LL_SPEC "%lld" #endif #ifdef ZTS