diff options
author | Hartmut Holzgraefe <hholzgra@php.net> | 2005-02-27 12:15:47 +0000 |
---|---|---|
committer | Hartmut Holzgraefe <hholzgra@php.net> | 2005-02-27 12:15:47 +0000 |
commit | 04f2f981e00ec999ed6fde4c163fdc44f9cb335e (patch) | |
tree | cee653dd8778ac1bb207341353b6c0a743d27e91 /ext/pdo_mysql/mysql_statement.c | |
parent | 81770f3c398ef9c6b9fa76f45c94533575f6f0af (diff) | |
download | php-git-04f2f981e00ec999ed6fde4c163fdc44f9cb335e.tar.gz |
changed the error checks on result set retrieval
UPDATEs not modifying anything are not actually bugs
Diffstat (limited to 'ext/pdo_mysql/mysql_statement.c')
-rwxr-xr-x | ext/pdo_mysql/mysql_statement.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/ext/pdo_mysql/mysql_statement.c b/ext/pdo_mysql/mysql_statement.c index 7f5530dbf2..7095cb8ec5 100755 --- a/ext/pdo_mysql/mysql_statement.c +++ b/ext/pdo_mysql/mysql_statement.c @@ -48,6 +48,7 @@ static int pdo_mysql_stmt_execute(pdo_stmt_t *stmt TSRMLS_DC) { pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data; pdo_mysql_db_handle *H = S->H; + my_ulonglong row_count; /* ensure that we free any previous unfetched results */ if (S->result) { @@ -59,17 +60,27 @@ static int pdo_mysql_stmt_execute(pdo_stmt_t *stmt TSRMLS_DC) pdo_mysql_error_stmt(stmt); return 0; } - if ((S->result = mysql_use_result(H->server)) == NULL) { - /* could've been INSERT/UPDATE/DELETE query */ - if (!mysql_affected_rows(H->server)) { + + row_count = mysql_affected_rows(H->server); + if (row_count == (my_ulonglong)-1) { + // we either have a query that returned a result set or an error occured + // lets see if we have access to a result set + S->result = mysql_use_result(H->server); + if (NULL == S->result) { pdo_mysql_error_stmt(stmt); return 0; } - return 1; - } - if (!stmt->executed) { - stmt->column_count = (int) mysql_num_fields(S->result); + + stmt->row_count = 0; + + if (!stmt->executed) { + stmt->column_count = (int) mysql_num_fields(S->result); + } + } else { + // this was a DML or DDL query (INSERT, UPDATE, DELETE, ... + stmt->row_count = row_count; } + return 1; } |