Re: PEAR::DB & persistence??

From: Date: Tue, 24 Jun 2003 18:26:36 +0000
Subject: Re: PEAR::DB & persistence??
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-6213@lists.php.net to get a copy of this message
After a little research and some help it's just a matter of resetting the internal pointer of the result set. Is there a PEAR::DB method that does this?
        $rownum=0;
        while ( $row = $result->fetchRow(DB_FETCHMODE_ASSOC, $rownum)) {
                $rownum++
                .... whatever ....
        }
graham At 11:46 AM 6/23/2003 -0700, Graham Clarke wrote:
Using PEAR::DB w/ Postgres -- I'm finding that once I fetch rows from a DB result set, the result set is empty. See example code below. Is this the expected behavior or am I missing something? Thanks Graham Using the following code example -- var_dump($a) is as expected var_dump($b) is empty
        $sql    = "SELECT * FROM myTable";
        $result = $db->query($sql);
        $a              = array();      // array to hold data
        while ( $mydata = $result->fetchRow(DB_FETCHMODE_ASSOC)) {
                        $thisdata = array(
                                        'col_1'         => $mydata['col_1],
                                        'col_2'         => $mydata['col_2],
                                        'col_2'         => $mydata['col_2]
                                          );
                $a[] = $thisdata;
                }
        $b              = array();      // array to hold data
        while ( $mydata = $result->fetchRow(DB_FETCHMODE_ASSOC)) {
                        $thisdata = array(
                                        'col_1'         => $mydata['col_1],
                                        'col_2'         => $mydata['col_2],
                                        'col_2'         => $mydata['col_2]
                                          );
                $b[] = $thisdata;
                }
Graham Clarke GrahamC@53Tech.com www.53Tech.com 603.643.9955 -- PEAR General Mailing List (http://pear.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Graham Clarke GrahamC@53Tech.com www.53Tech.com 603.643.9955

« previous php.pear.general (#6213) next »