Re: PEAR::DB question
| From: | (Terry Riley) | Date: | Tue, 29 Jul 2003 07:36:00 +0000 |
| Subject: | Re: PEAR::DB question | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-29552@lists.php.net to get a copy of this message | ||
Jake
Dunno if this will help, whether you're using MySQL or whether it works in
PEAR. Look up mysql_data_seek() in the php manual.
Cheers
Terry
----------Original Message---------
> 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