From: David Coallier Date: Tue, 4 Nov 2008 18:28:41 +0000 (+0000) Subject: - MFH X-Git-Tag: BEFORE_NS_RULES_CHANGE~96 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=80e3ed56307174b62cfc6aeeea4f8906ee62d24e;p=php - MFH - Bug #44154: [DOC] Return 3 elements at all times. If the dbh stmt doesn't have an error code we used to return an array with one element. For the sake of consistency and verification of returned values at userland we are now returning an array with 3 elements. Note the two last elements are null but present - Bug #4413: [DOC] If the error code returned by the DBH is null, we return a null value. This is used in order to help with empty error codes. --- diff --git a/ext/pdo/pdo_dbh.c b/ext/pdo/pdo_dbh.c index 2d3d20c0d4..e071ca8958 100755 --- a/ext/pdo/pdo_dbh.c +++ b/ext/pdo/pdo_dbh.c @@ -983,6 +983,11 @@ static PHP_METHOD(PDO, errorCode) RETURN_STRING(dbh->query_stmt->error_code, 1); } + if (dbh->error_code[0] == '\0') { + RETURN_NULL(); + } + + // Then we get back to the default fallback RETURN_STRING(dbh->error_code, 1); } /* }}} */ @@ -1004,6 +1009,8 @@ static PHP_METHOD(PDO, errorInfo) add_next_index_string(return_value, dbh->query_stmt->error_code, 1); } else { add_next_index_string(return_value, dbh->error_code, 1); + add_next_index_null(return_value); + add_next_index_null(return_value); } if (dbh->methods->fetch_err) { dbh->methods->fetch_err(dbh, dbh->query_stmt, return_value TSRMLS_CC);