From: Andrey Hristov Date: Tue, 12 Jul 2005 19:22:05 +0000 (+0000) Subject: strictly check the result of mysql_affected_rows() X-Git-Tag: php-5.1.0b3~24 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8899425e26b8d9653e122b5b4aee8a410040146a;p=php strictly check the result of mysql_affected_rows() --- diff --git a/ext/pdo_mysql/mysql_driver.c b/ext/pdo_mysql/mysql_driver.c index b57599c322..08b4429880 100755 --- a/ext/pdo_mysql/mysql_driver.c +++ b/ext/pdo_mysql/mysql_driver.c @@ -225,7 +225,8 @@ static long mysql_handle_doer(pdo_dbh_t *dbh, const char *sql, long sql_len TSRM pdo_mysql_error(dbh); return -1; } else { - return mysql_affected_rows(H->server); + my_ulonglong c= mysql_affected_rows(H->server); + return c != (my_ulonglong)-1 ? c:-1; } } diff --git a/ext/pdo_mysql/mysql_statement.c b/ext/pdo_mysql/mysql_statement.c index 0051313b71..6527496e75 100755 --- a/ext/pdo_mysql/mysql_statement.c +++ b/ext/pdo_mysql/mysql_statement.c @@ -155,9 +155,12 @@ static int pdo_mysql_stmt_execute(pdo_stmt_t *stmt TSRMLS_DC) } } - - stmt->row_count = mysql_stmt_affected_rows(S->stmt); - return 1; + ; + if ((row_count= mysql_stmt_affected_rows(S->stmt)) != (my_ulonglong)-1) { + stmt->row_count = row_count; + return 1; + } + return 0; } #endif /* ensure that we free any previous unfetched results */ @@ -222,7 +225,11 @@ static int pdo_mysql_stmt_next_rowset(pdo_stmt_t *stmt TSRMLS_DC) /* No more results */ return 0; } else { - row_count = mysql_affected_rows(H->server); + if ((my_ulonglong)-1 == (row_count = mysql_affected_rows(H->server))) { + pdo_mysql_error_stmt(stmt); + return 0; + } + if (!H->buffered) { S->result = mysql_use_result(H->server); } else {