summaryrefslogtreecommitdiff
path: root/ext/mysqli
diff options
context:
space:
mode:
authorGeorg Richter <georg@php.net>2004-11-01 07:19:26 +0000
committerGeorg Richter <georg@php.net>2004-11-01 07:19:26 +0000
commitb8863135a2202013c48d2933c61183279e44ae60 (patch)
treeaedb8780d82271107d1566e1310dca85d8fde7f5 /ext/mysqli
parent5b95dc5faf2367c3fdc14ca6c8bf4b2b71ca6db3 (diff)
downloadphp-git-b8863135a2202013c48d2933c61183279e44ae60.tar.gz
Fixed tests for empty dates (see http://bugs.mysql.com/?id=6058)
Fixed memleak in mysqli_stmt_bind_result Fixed error handling for mysqli_multi_query
Diffstat (limited to 'ext/mysqli')
-rw-r--r--ext/mysqli/mysqli_api.c20
-rw-r--r--ext/mysqli/mysqli_nonapi.c17
-rw-r--r--ext/mysqli/tests/003.phpt2
-rw-r--r--ext/mysqli/tests/020.phpt2
4 files changed, 28 insertions, 13 deletions
diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c
index 3d333bcbfa..4e3dda9d3f 100644
--- a/ext/mysqli/mysqli_api.c
+++ b/ext/mysqli/mysqli_api.c
@@ -217,6 +217,16 @@ PHP_FUNCTION(mysqli_stmt_bind_result)
zval *mysql_stmt;
MYSQL_BIND *bind;
+ if (getThis()) {
+ start = 0;
+ }
+
+ if (zend_parse_method_parameters((getThis()) ? 0:1 TSRMLS_CC, getThis(), "O", &mysql_stmt, mysqli_stmt_class_entry) == FAILURE) {
+ return;
+ }
+
+ MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt");
+
if (argc < (getThis() ? 1 : 2)) {
WRONG_PARAM_COUNT;
}
@@ -228,16 +238,6 @@ PHP_FUNCTION(mysqli_stmt_bind_result)
WRONG_PARAM_COUNT;
}
- if (getThis()) {
- start = 0;
- }
-
- if (zend_parse_method_parameters((getThis()) ? 0:1 TSRMLS_CC, getThis(), "O", &mysql_stmt, mysqli_stmt_class_entry) == FAILURE) {
- return;
- }
-
- MYSQLI_FETCH_RESOURCE(stmt, MY_STMT *, &mysql_stmt, "mysqli_stmt");
-
var_cnt = argc - start;
if (var_cnt != mysql_stmt_field_count(stmt->stmt)) {
diff --git a/ext/mysqli/mysqli_nonapi.c b/ext/mysqli/mysqli_nonapi.c
index cf6fe7960c..0429281675 100644
--- a/ext/mysqli/mysqli_nonapi.c
+++ b/ext/mysqli/mysqli_nonapi.c
@@ -222,8 +222,23 @@ PHP_FUNCTION(mysqli_multi_query)
MYSQLI_ENABLE_MQ;
if (mysql_real_query(mysql->mysql, query, query_len)) {
- MYSQLI_DISABLE_MQ;
+ char s_error[MYSQL_ERRMSG_SIZE], s_sqlstate[SQLSTATE_LENGTH+1];
+ unsigned int s_errno;
MYSQLI_REPORT_MYSQL_ERROR(mysql->mysql);
+
+ /* we have to save error information, cause
+ MYSQLI_DISABLE_MQ will reset error information */
+ strcpy(s_error, mysql_error(mysql->mysql));
+ strcpy(s_sqlstate, mysql_sqlstate(mysql->mysql));
+ s_errno = mysql_errno(mysql->mysql);
+
+ MYSQLI_DISABLE_MQ;
+
+ /* restore error information */
+ strcpy(mysql->mysql->net.last_error, s_error);
+ strcpy(mysql->mysql->net.sqlstate, s_sqlstate);
+ mysql->mysql->net.last_errno = s_errno;
+
RETURN_FALSE;
}
RETURN_TRUE;
diff --git a/ext/mysqli/tests/003.phpt b/ext/mysqli/tests/003.phpt
index 5535e9fb40..906bf28dec 100644
--- a/ext/mysqli/tests/003.phpt
+++ b/ext/mysqli/tests/003.phpt
@@ -50,7 +50,7 @@ array(7) {
[4]=>
string(19) "2010-07-10 00:00:00"
[5]=>
- string(0) ""
+ string(19) "0000-00-00 00:00:00"
[6]=>
string(19) "1999-12-29 00:00:00"
}
diff --git a/ext/mysqli/tests/020.phpt b/ext/mysqli/tests/020.phpt
index 5aa244329f..d08930fed9 100644
--- a/ext/mysqli/tests/020.phpt
+++ b/ext/mysqli/tests/020.phpt
@@ -58,7 +58,7 @@ array(7) {
[4]=>
string(19) "2010-07-10 00:00:00"
[5]=>
- string(0) ""
+ string(19) "0000-00-00 00:00:00"
[6]=>
string(19) "1999-12-29 00:00:00"
}