RE: [PHP-DB] best way to iterate through DB_Result the second time around?

From: Date: Mon, 03 Feb 2003 04:22:19 +0000
Subject: RE: [PHP-DB] best way to iterate through DB_Result the second time around?
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-25360@lists.php.net to get a copy of this message
> Iterating over a result set is eaasy the first time; > > while( $group_data = $result->fetchRow( DB_FETCHMODE_ASSOC ) ) > { > blah....... > } > > > How come DB_Result doesn't have a reset() function so you can iterate over > the result set a second time without having to resort to this sort of > thing? > > for( $i = 0; $i < $result->numRows(); $i++ ) // Have to iterate through > > // result set on the second > pass > { > $group_data = $result->fetchRow( DB_FETCHMODE_ASSOC, $i ); > blah...... > } It depends on your database... If you're using MySQL, see if whatever class you're using has a wrapper for mysql_data_seek(). It will do what you want rather easily. ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/

« previous php.db (#25360) next »