]> 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:11:46 +0000 (22:11 +0000)
committerGeorg Richter <georg@php.net>
Thu, 12 Aug 2004 22:11:46 +0000 (22:11 +0000)
ext/mysqli/mysqli_api.c

index ac5f0b80cd95df234017ee01833a7b8c56263e08..773f2758d742d8926441f25848463d7766e55cba 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;
                }