PEAR::DB question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello-
    I'm using the fetch method to get a result set.  ie-

$sql = "select id,name from sr_names order by name";
$result = $db->query($sql);
while ( $row = $result->fetchRow(DB_FETCHMODE_ASSOC) )
    echo $row['id'] . ' ' . $row['name'] . "<br>";

    This works great!  Now, I want to _re-use_ this result set without
having to re-query the database.  Then cycle through the result set.  ie -

$result->someFunction();
while ( $row = $result->fetchRow(DB_FETCHMODE_ASSOC) )
    echo $row['id'] . ' ' . $row['name'] . "<br>";

    So, the output here would be two of whatever was output.  Does that make
sense?  Right now I'm having to do this:

$sql = "select id,name from sr_names order by name";
$result = $db->query($sql);
while ( $row = $result->fetchRow(DB_FETCHMODE_ASSOC) )
    echo $row['id'] . ' ' . $row['name'] . "<br>";
$result = $db->query($sql);
while ( $row = $result->fetchRow(DB_FETCHMODE_ASSOC) )
    echo $row['id'] . ' ' . $row['name'] . "<br>";

    If I already have the result set, can't I just tell it "hey, put the
cursor back at the top".  I know I can fetchRow from a specific row in the
result set, but then I'd have to get every row that way, which doesn't make
efficiency sense, either.
    Thanks in advance,

Jake

LandEZ



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux