matched rows function for PDO

[email protected] (Amr Shahin) Tue, 26 May 2009 19:37:12 +0300
Newsgroups svn.migration
Message-ID <[email protected]>
Hello
i have added a matchedRows to PDO, and implemented it on the mysql driver
i hope im doing this correctly since this is the first time im uploading a
change to php
u can find the patch files attached
pdo.patch (text/x-diff, 2.3 KB)
Only in pdo: acinclude.m4
Only in pdo: aclocal.m4
Only in pdo: autom4te.cache
Only in pdo: build
Only in pdo: config.guess
Only in pdo: config.h
Only in pdo: config.h.in
Only in pdo: config.log
Only in pdo: config.nice
Only in pdo: config.status
Only in pdo: config.sub
Only in pdo: configure
Only in pdo: configure.in
Only in pdo: .deps
Only in pdo: include
Only in pdo: install-sh
Only in pdo: libtool
Only in pdo: ltmain.sh
Only in pdo: Makefile
Only in pdo: Makefile.fragments
Only in pdo: Makefile.global
Only in pdo: Makefile.objects
Only in pdo: missing
Only in pdo: mkinstalldirs
Only in pdo: modules
diff -crB pdo/pdo_stmt.c pdo.original/pdo_stmt.c
*** pdo/pdo_stmt.c	2009-05-26 19:19:53.000000000 +0300
--- pdo.original/pdo_stmt.c	2009-05-26 19:20:12.000000000 +0300
***************
*** 1668,1686 ****
  
  	RETURN_LONG(stmt->row_count);
  }
- 
- 
- /* {{{ proto int PDOStatement::rowsMatched()
-    Returns the number of rows in a result set, or the number of rows matched by the last execute().  It is not always meaningful. */
-     //a by Amr Shahin <[email protected]> 
-     //26-5-2009
- static PHP_METHOD(PDOStatement, rowsMatched)
- {
-     PHP_STMT_GET_OBJ;
- 
-     RETURN_LONG(stmt->matchedRows);
- }
- 
  /* }}} */
  
  /* {{{ proto string PDOStatement::errorCode()
--- 1668,1673 ----
***************
*** 2139,2145 ****
  	PHP_ME(PDOStatement, bindColumn,	second_arg_force_ref,	ZEND_ACC_PUBLIC)
  	PHP_ME(PDOStatement, bindValue,		NULL,					ZEND_ACC_PUBLIC)
  	PHP_ME(PDOStatement, rowCount,		NULL,					ZEND_ACC_PUBLIC)
-         PHP_ME(PDOStatement, rowsMatched,	NULL,					ZEND_ACC_PUBLIC)
  	PHP_ME(PDOStatement, fetchColumn,	NULL,					ZEND_ACC_PUBLIC)
  	PHP_ME(PDOStatement, fetchAll,		NULL,					ZEND_ACC_PUBLIC)
  	PHP_ME(PDOStatement, fetchObject,	NULL,					ZEND_ACC_PUBLIC)
--- 2126,2131 ----
diff -crB pdo/php_pdo_driver.h pdo.original/php_pdo_driver.h
*** pdo/php_pdo_driver.h	2009-05-26 19:19:53.000000000 +0300
--- pdo.original/php_pdo_driver.h	2009-05-26 19:20:12.000000000 +0300
***************
*** 584,594 ****
  
  	/* not always meaningful */
  	long row_count;
-         
-         /* not always meaningful */
-         //added by Amr Shahin <[email protected]> 
-         //26-5-2009
-         long matchedRows;
  
  	/* used to hold the statement's current query */
  	char *query_string;
--- 584,589 ----
Only in pdo: run-tests.php
pdo_mysql.patch (text/x-diff, 3.3 KB)
Only in pdo_mysql: acinclude.m4
Only in pdo_mysql: aclocal.m4
Only in pdo_mysql: autom4te.cache
Only in pdo_mysql: build
Only in pdo_mysql: config.guess
Only in pdo_mysql: config.h
Only in pdo_mysql: config.h.in
Only in pdo_mysql: config.log
Only in pdo_mysql: config.nice
Only in pdo_mysql: config.status
Only in pdo_mysql: config.sub
Only in pdo_mysql: configure
Only in pdo_mysql: configure.in
Only in pdo_mysql: .deps
Only in pdo_mysql: include
Only in pdo_mysql: install-sh
Only in pdo_mysql: libtool
Only in pdo_mysql: ltmain.sh
Only in pdo_mysql: Makefile
Only in pdo_mysql: Makefile.fragments
Only in pdo_mysql: Makefile.global
Only in pdo_mysql: Makefile.objects
Only in pdo_mysql: missing
Only in pdo_mysql: mkinstalldirs
Only in pdo_mysql: modules
diff -crB pdo_mysql/mysql_statement.c pdo_mysql.original/mysql_statement.c
*** pdo_mysql/mysql_statement.c	2009-05-26 19:22:17.000000000 +0300
--- pdo_mysql.original/mysql_statement.c	2009-05-26 19:22:41.000000000 +0300
***************
*** 86,140 ****
  	return 1;
  }
  
- #define ROWS_MATCHED 1
- #define ROWS_MATCHED_INFO "Rows matched: "
- #define MAX_MATCHED_LEN 100
- 
- static long parseMysqlRowsMatched( const char *pcInfo )
- {
-     const char *pcLocation = NULL;
-     pcLocation = strstr( pcInfo , ROWS_MATCHED_INFO );
-     if( ! pcLocation ) {
-         return 0;
-     }
-     
-     char acRowsMatched[MAX_MATCHED_LEN] = {0};
-     pcLocation += strlen( ROWS_MATCHED_INFO );
-     
-     int i = 0;
-     int iLocationPointer = 0;
-     while( isdigit( pcLocation[i] ) ) {
-         acRowsMatched[iLocationPointer++] = pcLocation[i];
-         i++;
-     }
-     
-     return atoi( acRowsMatched );
-     
- }
- 
- 
- static long parseMysqlInfo( const char *pcInfo , int mode )
- {
-     switch( mode )
-     {
-         case ROWS_MATCHED:
-             return parseMysqlRowsMatched( pcInfo );
-             break;
-         default:
-             return 0;
-     }
-     
-     return 0;
- }
- 
  static int pdo_mysql_stmt_execute(pdo_stmt_t *stmt TSRMLS_DC)
  {
-     
  	pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data;
  	pdo_mysql_db_handle *H = S->H;
  	my_ulonglong row_count;
-         const char *pcMysqlInfo = NULL ;
-         long matchedRows = 0;
  #if HAVE_MYSQL_STMT_PREPARE
  	int i;
  
--- 86,96 ----
***************
*** 243,256 ****
  			}
  		}
  
-                 //change by Amr Shahin <[email protected]> 
-                 //26-5-2009
  		row_count = mysql_stmt_affected_rows(S->stmt);
-                 pcMysqlInfo = mysql_info(H->server);
-                 
-                 matchedRows = parseMysqlInfo( pcMysqlInfo , ROWS_MATCHED );
-                 
-                 stmt->matchedRows = matchedRows ;
  		if (row_count != (my_ulonglong)-1) {
  			stmt->row_count = row_count;
  		}
--- 199,205 ----
***************
*** 268,282 ****
  		return 0;
  	}
  
-         pcMysqlInfo = mysql_info(H->server);
-                 
  	row_count = mysql_affected_rows(H->server);
-     
-         //change by Amr Shahin <[email protected]> 
-         //26-5-2009
-         matchedRows = parseMysqlInfo( pcMysqlInfo , ROWS_MATCHED );
-         stmt->matchedRows = matchedRows ;
- 
  	if (row_count == (my_ulonglong)-1) {
  		/* we either have a query that returned a result set or an error occured
  		   lets see if we have access to a result set */
--- 217,223 ----
Only in pdo_mysql: run-tests.php