From 4af80c7f90dbab70ace32d566730b50a72beaacc Mon Sep 17 00:00:00 2001 From: David Coallier Date: Tue, 4 Nov 2008 18:25:26 +0000 Subject: [PATCH] - 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 #44153: [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. --- ext/pdo/pdo_dbh.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ext/pdo/pdo_dbh.c b/ext/pdo/pdo_dbh.c index 5dfe451d5f..21b11c8972 100755 --- a/ext/pdo/pdo_dbh.c +++ b/ext/pdo/pdo_dbh.c @@ -988,7 +988,12 @@ static PHP_METHOD(PDO, errorCode) if (dbh->query_stmt) { RETURN_STRING(dbh->query_stmt->error_code, 1); } - + + if (dbh->error_code[0] == '\0') { + RETURN_NULL(); + } + + // Fallback to default documented value RETURN_STRING(dbh->error_code, 1); } /* }}} */ @@ -1010,6 +1015,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); -- 2.50.1