davidc Mon Nov 10 20:34:53 2008 UTC
Modified files:
/php-src/ext/pdo pdo_dbh.c pdo_stmt.c
Log:
- MFB (Which was an MFH)
- Bug #44153 (ErrorCode returns NULL when no error)
- Bug #44154 (ErrorInfo to ALWAYS have 3 elements)
http://cvs.php.net/viewvc.cgi/php-src/ext/pdo/pdo_dbh.c?r1=1.154&r2=1.155&diff_format=u
Index: php-src/ext/pdo/pdo_dbh.c
diff -u php-src/ext/pdo/pdo_dbh.c:1.154 php-src/ext/pdo/pdo_dbh.c:1.155
--- php-src/ext/pdo/pdo_dbh.c:1.154 Tue Nov 4 18:25:26 2008
+++ php-src/ext/pdo/pdo_dbh.c Mon Nov 10 20:34:53 2008
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: pdo_dbh.c,v 1.154 2008/11/04 18:25:26 davidc Exp $ */
+/* $Id: pdo_dbh.c,v 1.155 2008/11/10 20:34:53 davidc Exp $ */
/* The PDO Database Handle Class */
@@ -1002,11 +1002,16 @@
Fetch extended error information associated with the last operation on the
database handle */
static PHP_METHOD(PDO, errorInfo)
{
+ int error_count;
+ int error_count_diff = 0;
+ int error_expected_count = 3;
+
pdo_dbh_t *dbh = zend_object_store_get_object(getThis() TSRMLS_CC);
if (zend_parse_parameters_none() == FAILURE) {
return;
}
+
PDO_CONSTRUCT_CHECK;
array_init(return_value);
@@ -1015,12 +1020,28 @@
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);
}
+
+ /**
+ * In order to be consistent, we have to make sure we add the good
amount
+ * of null elements depending on the current number of elements. We make
+ * a simple difference and add the needed elements to reach the expected
+ * count.
+ */
+ error_count = zend_hash_num_elements(Z_ARRVAL_P(return_value));
+
+ if (error_expected_count > error_count) {
+ error_count_diff = error_expected_count - error_count;
+
+ int current_index;
+ for (current_index = 0; current_index > error_count_diff;
current_index++) {
+ add_next_index_null(return_value);
+ }
+ }
}
/* }}} */
http://cvs.php.net/viewvc.cgi/php-src/ext/pdo/pdo_stmt.c?r1=1.208&r2=1.209&diff_format=u
Index: php-src/ext/pdo/pdo_stmt.c
diff -u php-src/ext/pdo/pdo_stmt.c:1.208 php-src/ext/pdo/pdo_stmt.c:1.209
--- php-src/ext/pdo/pdo_stmt.c:1.208 Wed Nov 5 23:39:09 2008
+++ php-src/ext/pdo/pdo_stmt.c Mon Nov 10 20:34:53 2008
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: pdo_stmt.c,v 1.208 2008/11/05 23:39:09 felipe Exp $ */
+/* $Id: pdo_stmt.c,v 1.209 2008/11/10 20:34:53 davidc Exp $ */
/* The PDO Statement Handle Class */
@@ -1784,6 +1784,10 @@
Fetch extended error information associated with the last operation on the
statement handle */
static PHP_METHOD(PDOStatement, errorInfo)
{
+ int error_count;
+ int error_count_diff = 0;
+ int error_expected_count = 3;
+
PHP_STMT_GET_OBJ;
if (zend_parse_parameters_none() == FAILURE) {
@@ -1796,6 +1800,17 @@
if (stmt->dbh->methods->fetch_err) {
stmt->dbh->methods->fetch_err(stmt->dbh, stmt, return_value
TSRMLS_CC);
}
+
+ error_count = zend_hash_num_elements(Z_ARRVAL_P(return_value));
+
+ if (error_expected_count > error_count) {
+ error_count_diff = error_expected_count - error_count;
+
+ int current_index;
+ for (current_index = 0; current_index < error_count_diff;
current_index++) {
+ add_next_index_null(return_value);
+ }
+ }
}
/* }}} */
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php