[PHP-CVS] cvs: php-src(PHP_5_3) /ext/pdo pdo_dbh.c pdo_stmt.c

2008-11-13 Thread Pierre-Alain Joye
pajoye  Thu Nov 13 14:40:06 2008 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/pdopdo_dbh.c pdo_stmt.c 
  Log:
  - MFH: declaration goes first...
  
http://cvs.php.net/viewvc.cgi/php-src/ext/pdo/pdo_dbh.c?r1=1.82.2.31.2.17.2.15r2=1.82.2.31.2.17.2.16diff_format=u
Index: php-src/ext/pdo/pdo_dbh.c
diff -u php-src/ext/pdo/pdo_dbh.c:1.82.2.31.2.17.2.15 
php-src/ext/pdo/pdo_dbh.c:1.82.2.31.2.17.2.16
--- php-src/ext/pdo/pdo_dbh.c:1.82.2.31.2.17.2.15   Mon Nov 10 18:47:28 2008
+++ php-src/ext/pdo/pdo_dbh.c   Thu Nov 13 14:40:06 2008
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: pdo_dbh.c,v 1.82.2.31.2.17.2.15 2008/11/10 18:47:28 davidc Exp $ */
+/* $Id: pdo_dbh.c,v 1.82.2.31.2.17.2.16 2008/11/13 14:40:06 pajoye Exp $ */
 
 /* The PDO Database Handle Class */
 
@@ -1031,9 +1031,9 @@
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;
+
+   error_count_diff = error_expected_count - error_count;
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.118.2.38.2.24.2.35r2=1.118.2.38.2.24.2.36diff_format=u
Index: php-src/ext/pdo/pdo_stmt.c
diff -u php-src/ext/pdo/pdo_stmt.c:1.118.2.38.2.24.2.35 
php-src/ext/pdo/pdo_stmt.c:1.118.2.38.2.24.2.36
--- php-src/ext/pdo/pdo_stmt.c:1.118.2.38.2.24.2.35 Mon Nov 10 18:47:28 2008
+++ php-src/ext/pdo/pdo_stmt.c  Thu Nov 13 14:40:06 2008
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: pdo_stmt.c,v 1.118.2.38.2.24.2.35 2008/11/10 18:47:28 davidc Exp $ */
+/* $Id: pdo_stmt.c,v 1.118.2.38.2.24.2.36 2008/11/13 14:40:06 pajoye Exp $ */
 
 /* The PDO Statement Handle Class */
 
@@ -1810,9 +1810,9 @@
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;
+
+   error_count_diff = error_expected_count - error_count;
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



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/pdo pdo_dbh.c pdo_stmt.c

2008-11-10 Thread David Coallier
davidc  Mon Nov 10 18:47:28 2008 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/pdopdo_dbh.c pdo_stmt.c 
  Log:
  - After readying Johannes's mail, the conclusion that a smarter system
to find out if the return_value had the correct number of elements was
definitely needed. Simply added a difference to both dbh and stmt to
make sure that the error info always has 3 elements.
  
  - Bug #44154 (pdo-errorInfo doesn't always return three elements)
  - Now pdo-errorInfo() AND stmt-errorInfo() return three elements.
  
  - [DOC] Make sure that not only the pdo-errorInfo() is returning 3 elms, but
also the PDOStatement object
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/pdo/pdo_dbh.c?r1=1.82.2.31.2.17.2.14r2=1.82.2.31.2.17.2.15diff_format=u
Index: php-src/ext/pdo/pdo_dbh.c
diff -u php-src/ext/pdo/pdo_dbh.c:1.82.2.31.2.17.2.14 
php-src/ext/pdo/pdo_dbh.c:1.82.2.31.2.17.2.15
--- php-src/ext/pdo/pdo_dbh.c:1.82.2.31.2.17.2.14   Tue Nov  4 18:28:41 2008
+++ php-src/ext/pdo/pdo_dbh.c   Mon Nov 10 18:47:28 2008
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: pdo_dbh.c,v 1.82.2.31.2.17.2.14 2008/11/04 18:28:41 davidc Exp $ */
+/* $Id: pdo_dbh.c,v 1.82.2.31.2.17.2.15 2008/11/10 18:47:28 davidc Exp $ */
 
 /* The PDO Database Handle Class */
 
@@ -987,7 +987,10 @@
RETURN_NULL();
}
 
-   // Then we get back to the default fallback
+   /**
+* Making sure that we fallback to the default implementation
+* if the dbh-error_code is not null.
+*/
RETURN_STRING(dbh-error_code, 1);
 }
 /* }}} */
@@ -996,11 +999,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);
@@ -1009,12 +1017,27 @@
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 nulls depending on the current number of elements. We make a 
simple
+* difference and add the needed elements
+*/
+   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.118.2.38.2.24.2.34r2=1.118.2.38.2.24.2.35diff_format=u
Index: php-src/ext/pdo/pdo_stmt.c
diff -u php-src/ext/pdo/pdo_stmt.c:1.118.2.38.2.24.2.34 
php-src/ext/pdo/pdo_stmt.c:1.118.2.38.2.24.2.35
--- php-src/ext/pdo/pdo_stmt.c:1.118.2.38.2.24.2.34 Wed Nov  5 23:40:37 2008
+++ php-src/ext/pdo/pdo_stmt.c  Mon Nov 10 18:47:28 2008
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: pdo_stmt.c,v 1.118.2.38.2.24.2.34 2008/11/05 23:40:37 felipe Exp $ */
+/* $Id: pdo_stmt.c,v 1.118.2.38.2.24.2.35 2008/11/10 18:47:28 davidc Exp $ */
 
 /* The PDO Statement Handle Class */
 
@@ -1778,6 +1778,10 @@
return;
}
 
+   if (stmt-error_code[0] == '\0') {
+   RETURN_NULL();
+   }
+
RETURN_STRING(stmt-error_code, 1);
 }
 /* }}} */
@@ -1786,6 +1790,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) {
@@ -1798,6 +1806,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;