Patch pdo-pdo_mysql-patch for PDO related Bug #69016
Patch version 2015-02-08 18:23 UTC
Return to Bug #69016 |
Download this patch
Patch Revisions:
Developer: tugrultopuz@gmail.com
diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c
index 238f547..88557de 100644
--- a/ext/pdo/pdo_stmt.c
+++ b/ext/pdo/pdo_stmt.c
@@ -858,6 +858,8 @@ static int do_fetch(pdo_stmt_t *stmt, int do_bind, zval *return_value,
zval grp_val, *grp, **pgrp, *retval, *old_ctor_args = NULL;
int colno;
+ zend_function *function_handler;
+
if (how == PDO_FETCH_USE_DEFAULT) {
how = stmt->default_fetch_type;
}
@@ -1125,9 +1127,25 @@ static int do_fetch(pdo_stmt_t *stmt, int do_bind, zval *return_value,
case PDO_FETCH_CLASS:
if ((flags & PDO_FETCH_SERIALIZE) == 0 || idx) {
- zend_update_property(ce, return_value,
- stmt->columns[i].name, stmt->columns[i].namelen,
- val TSRMLS_CC);
+
+ if (zend_hash_find(&ce->function_table, "setcolumn", sizeof("setcolumn"), (void **) &function_handler) == SUCCESS) {
+
+ zval iv;
+ ZVAL_LONG(&iv, i);
+
+ zend_call_method(&return_value, ce, &function_handler, "setcolumn", sizeof("setcolumn"), &retval, 2, &iv, val TSRMLS_CC);
+
+ if (retval) {
+ zval_ptr_dtor(&retval);
+ retval = NULL;
+ }
+
+ } else {
+ zend_update_property(ce, return_value,
+ stmt->columns[i].name, stmt->columns[i].namelen,
+ val TSRMLS_CC);
+ }
+
zval_ptr_dtor(&val);
} else {
#ifdef MBO_0
diff --git a/ext/pdo_mysql/mysql_statement.c b/ext/pdo_mysql/mysql_statement.c
index 95501c2..7ce6d88 100644
--- a/ext/pdo_mysql/mysql_statement.c
+++ b/ext/pdo_mysql/mysql_statement.c
@@ -807,7 +807,7 @@ static int pdo_mysql_stmt_col_meta(pdo_stmt_t *stmt, long colno, zval *return_va
{
pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data;
const MYSQL_FIELD *F;
- zval *flags;
+ zval *flags, *ex_info;
char *str;
PDO_DBG_ENTER("pdo_mysql_stmt_col_meta");
@@ -817,13 +817,16 @@ static int pdo_mysql_stmt_col_meta(pdo_stmt_t *stmt, long colno, zval *return_va
}
if (colno >= stmt->column_count) {
/* error invalid column */
- PDO_DBG_RETURN(FAILURE);
+ PDO_DBG_RETURN(FAILURE);
}
array_init(return_value);
MAKE_STD_ZVAL(flags);
array_init(flags);
+ MAKE_STD_ZVAL(ex_info);
+ array_init(ex_info);
+
F = S->fields + colno;
if (F->def) {
@@ -849,6 +852,30 @@ static int pdo_mysql_stmt_col_meta(pdo_stmt_t *stmt, long colno, zval *return_va
add_assoc_string(return_value, "native_type", str, 1);
}
+ if (F->name) {
+ add_assoc_stringl(ex_info, "name", F->name, F->name_length, 1);
+ }
+
+ if (F->org_name) {
+ add_assoc_stringl(ex_info, "org_name", F->org_name, F->org_name_length, 1);
+ }
+
+ if (F->table) {
+ add_assoc_stringl(ex_info, "table", F->table, F->table_length, 1);
+ }
+
+ if (F->org_table) {
+ add_assoc_stringl(ex_info, "org_table", F->org_table, F->org_table_length, 1);
+ }
+
+ if (F->db) {
+ add_assoc_stringl(ex_info, "db", F->db, F->db_length, 1);
+ }
+
+ if (F->catalog) {
+ add_assoc_stringl(ex_info, "catalog", F->catalog, F->catalog_length, 1);
+ }
+
#ifdef PDO_USE_MYSQLND
switch (F->type) {
case MYSQL_TYPE_BIT:
@@ -869,6 +896,7 @@ static int pdo_mysql_stmt_col_meta(pdo_stmt_t *stmt, long colno, zval *return_va
#endif
add_assoc_zval(return_value, "flags", flags);
+ add_assoc_zval(return_value, "ex_info", ex_info);
add_assoc_string(return_value, "table", (char *) (F->table?F->table:""), 1);
PDO_DBG_RETURN(SUCCESS);
} /* }}} */
|