cvs: php-src(PHP_5_1) /ext/pdo pdo_stmt.c

From: Date: Mon, 31 Oct 2005 03:23:41 +0000
Subject: cvs: php-src(PHP_5_1) /ext/pdo pdo_stmt.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-34903@lists.php.net to get a copy of this message
wez Sun Oct 30 22:23:41 2005 EDT Modified files: (Branch: PHP_5_1) /php-src/ext/pdo pdo_stmt.c Log: fix misinterpretation of data when overriding types via bindColumn. Very slightly modified patch from Marcus. http://cvs.php.net/diff.php/php-src/ext/pdo/pdo_stmt.c?r1=1.118.2.13&r2=1.118.2.14&ty=u Index: php-src/ext/pdo/pdo_stmt.c diff -u php-src/ext/pdo/pdo_stmt.c:1.118.2.13 php-src/ext/pdo/pdo_stmt.c:1.118.2.14 --- php-src/ext/pdo/pdo_stmt.c:1.118.2.13 Sun Oct 30 21:07:37 2005 +++ php-src/ext/pdo/pdo_stmt.c Sun Oct 30 22:23:38 2005 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pdo_stmt.c,v 1.118.2.13 2005/10/31 02:07:37 wez Exp $ */ +/* $Id: pdo_stmt.c,v 1.118.2.14 2005/10/31 03:23:38 wez Exp $ */ /* The PDO Statement Handle Class */ @@ -443,10 +443,11 @@ char *value = NULL; unsigned long value_len = 0; int caller_frees = 0; - int type; + int type, new_type; col = &stmt->columns[colno]; - type = type_override ? PDO_PARAM_TYPE(*type_override) : PDO_PARAM_TYPE(col->param_type); + type = PDO_PARAM_TYPE(col->param_type); + new_type = type_override ? PDO_PARAM_TYPE(*type_override) : type; value = NULL; value_len = 0; @@ -474,7 +475,7 @@ if (value == NULL) { ZVAL_NULL(dest); } else if (value_len == 0) { - if (stmt->dbh->stringify) { + if (stmt->dbh->stringify || new_type == PDO_PARAM_STR) { char *buf = NULL; size_t len; len = php_stream_copy_to_mem((php_stream*)value, &buf, PHP_STREAM_COPY_ALL, 0); @@ -483,7 +484,7 @@ } else { php_stream_to_zval((php_stream*)value, dest); } - } else if (!stmt->dbh->stringify) { + } else if (!stmt->dbh->stringify && new_type != PDO_PARAM_STR) { /* they gave us a string, but LOBs are represented as streams in PDO */ php_stream *stm; #ifdef TEMP_STREAM_TAKE_BUFFER @@ -517,6 +518,25 @@ ZVAL_NULL(dest); } + if (type != new_type) { + switch (new_type) { + case PDO_PARAM_INT: + convert_to_long_ex(&dest); + break; + case PDO_PARAM_BOOL: + convert_to_boolean_ex(&dest); + break; + case PDO_PARAM_STR: + convert_to_string_ex(&dest); + break; + case PDO_PARAM_NULL: + convert_to_null_ex(&dest); + break; + default: + ; + } + } + if (caller_frees && value) { efree(value); }

« previous php.cvs (#34903) next »