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;
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);
} 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
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);
}