diff options
Diffstat (limited to 'ext/pdo_mysql/mysql_statement.c')
-rw-r--r-- | ext/pdo_mysql/mysql_statement.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/ext/pdo_mysql/mysql_statement.c b/ext/pdo_mysql/mysql_statement.c index 00a2583cdf..616c5bf9c4 100644 --- a/ext/pdo_mysql/mysql_statement.c +++ b/ext/pdo_mysql/mysql_statement.c @@ -619,6 +619,11 @@ static int pdo_mysql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_da static int pdo_mysql_stmt_fetch(pdo_stmt_t *stmt, enum pdo_fetch_orientation ori, zend_long offset) /* {{{ */ { pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data; + + if (!S->result) { + PDO_DBG_RETURN(0); + } + #ifdef PDO_USE_MYSQLND zend_bool fetched_anything; @@ -632,6 +637,10 @@ static int pdo_mysql_stmt_fetch(pdo_stmt_t *stmt, enum pdo_fetch_orientation ori PDO_DBG_RETURN(1); } + + if (!S->stmt && S->current_data) { + mnd_free(S->current_data); + } #else int ret; @@ -655,16 +664,6 @@ static int pdo_mysql_stmt_fetch(pdo_stmt_t *stmt, enum pdo_fetch_orientation ori } #endif /* PDO_USE_MYSQLND */ - if (!S->result) { - strcpy(stmt->error_code, "HY000"); - PDO_DBG_RETURN(0); - } -#ifdef PDO_USE_MYSQLND - if (!S->stmt && S->current_data) { - mnd_free(S->current_data); - } -#endif /* PDO_USE_MYSQLND */ - if ((S->current_data = mysql_fetch_row(S->result)) == NULL) { if (!S->H->buffered && mysql_errno(S->H->server)) { pdo_mysql_error_stmt(stmt); |