From: Georg Richter Date: Thu, 12 Aug 2004 22:11:46 +0000 (+0000) Subject: minor fix in mysqli_prepare: copying stmt errormessag to mysql structure X-Git-Tag: php-5.0.2RC1~137 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bc4a269d3c75482af78851c2d67cb93d776e7d18;p=php minor fix in mysqli_prepare: copying stmt errormessag to mysql structure --- diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c index ac5f0b80cd..773f2758d7 100644 --- a/ext/mysqli/mysqli_api.c +++ b/ext/mysqli/mysqli_api.c @@ -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; }