Skip to content

Commit 1b34fa1

Browse files
committed
MFH:
* is_output and is_null parameters are now booleans instead of int in mssql_bind * Added missing conditional from old parameter parsing
1 parent 96d199d commit 1b34fa1

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

ext/mssql/php_mssql.c

+13-11
Original file line numberDiff line numberDiff line change
@@ -2009,23 +2009,28 @@ PHP_FUNCTION(mssql_init)
20092009
}
20102010
/* }}} */
20112011

2012-
/* {{{ proto bool mssql_bind(resource stmt, string param_name, mixed var, int type [, int is_output [, int is_null [, int maxlen]]])
2012+
/* {{{ proto bool mssql_bind(resource stmt, string param_name, mixed var, int type [, bool is_output [, bool is_null [, int maxlen]]])
20132013
Adds a parameter to a stored procedure or a remote stored procedure */
20142014
PHP_FUNCTION(mssql_bind)
20152015
{
20162016
char *param_name;
20172017
int param_name_len, datalen;
20182018
int status = 0;
2019-
long type = 0, is_output = 0, is_null = 0, maxlen = -1;
2019+
long type = 0, maxlen = -1;
20202020
zval *stmt, **var;
2021+
zend_bool is_output = 0, is_null = 0;
20212022
mssql_link *mssql_ptr;
20222023
mssql_statement *statement;
20232024
mssql_bind bind,*bindp;
20242025
LPBYTE value = NULL;
20252026

2026-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsZl|lll", &stmt, &param_name, &param_name_len, &var, &type, &is_output, &is_null, &maxlen) == FAILURE) {
2027+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsZl|bbl", &stmt, &param_name, &param_name_len, &var, &type, &is_output, &is_null, &maxlen) == FAILURE) {
20272028
return;
20282029
}
2030+
2031+
if (ZEND_NUM_ARGS() == 7 && !is_output) {
2032+
maxlen = -1;
2033+
}
20292034

20302035
ZEND_FETCH_RESOURCE(statement, mssql_statement *, &stmt, -1, "MS SQL-Statement", le_statement);
20312036

@@ -2039,24 +2044,21 @@ PHP_FUNCTION(mssql_bind)
20392044
if (is_null) {
20402045
maxlen=0;
20412046
datalen=0;
2042-
}
2043-
else {
2047+
} else {
20442048
convert_to_string_ex(var);
20452049
datalen=Z_STRLEN_PP(var);
20462050
value=(LPBYTE)Z_STRVAL_PP(var);
20472051
}
2048-
}
2049-
else { /* fixed-length type */
2052+
} else {
2053+
/* fixed-length type */
20502054
if (is_null) {
20512055
datalen=0;
2052-
}
2053-
else {
2056+
} else {
20542057
datalen=-1;
20552058
}
20562059
maxlen=-1;
20572060

2058-
switch (type) {
2059-
2061+
switch (type) {
20602062
case SQLFLT4:
20612063
case SQLFLT8:
20622064
case SQLFLTN:

0 commit comments

Comments
 (0)