]> granicus.if.org Git - php/commitdiff
minor fix in mysqli_prepare: copying stmt errormessag to mysql structure
authorGeorg Richter <georg@php.net>
Thu, 12 Aug 2004 22:14:06 +0000 (22:14 +0000)
committerGeorg Richter <georg@php.net>
Thu, 12 Aug 2004 22:14:06 +0000 (22:14 +0000)
ext/mysqli/mysqli_api.c

index 5345aa34fe607fdee33a96923d4ada5657d5952c..d6fa8fe6c258836332852e22c9766f61cd96b35f 100644 (file)
@@ -1243,6 +1243,12 @@ PHP_FUNCTION(mysqli_prepare)
 
        if ((stmt->stmt = mysql_stmt_init(mysql->mysql))) {
                if (mysql_stmt_prepare(stmt->stmt, query, query_len)) {
+                       if (stmt->stmt->last_errno) {
+                               /* if we close the statement handle, we have to copy the errors to connection handle */
+                               mysql->mysql->net.last_errno = stmt->stmt->last_errno;
+                               strcpy(mysql->mysql->net.last_error, stmt->stmt->last_error);
+                               strcpy(mysql->mysql->net.sqlstate, stmt->stmt->sqlstate);
+                       }
                        mysql_stmt_close(stmt->stmt);
                        stmt->stmt = NULL;
                }