On 2008-11-21 06:33:27 -0500, John Scoles wrote:
> Deviloper wrote:
> >like:
> >
> >my $db->connect(blablabla);
> >my $sth1 = $db->prepare("select * from animals");
> >$sth1->execute();
> >my $sth2 = $db->prepare("select * from pets");
> >$sth2->execute();
> >my $sth3 = $db->prepare("select * from fish");
> >$sth...
> >
> >while (my ($animal) = $sth2->fetch_array) {
> >  ...
> >}
> >
> >I can“t test myself because my the mysql db on my iphone
> >is broken and I have no other here at the moment :-(

> Yes of course and it is best practice to let a single DB handle generate all 
> the Statement handles in you code.

I think the OP may have meant something different: Is it possible to
start fetching from one statement handle before you are finished with
the other?

In general, yes, this is possible, but it depends on the database.

MySQL in particular doesn't support multiple open cursors (at least in
5.0, IIRC).  However, DBD::mysql gets around this limitation by reading
the complete resultset into memory in execute, and fetch_* just reads
from the already cached data. So, as far as the DBI programmer is
concerned, multiple open cursors are allowed (until the resultset is too
large to fit into memory - then you need to turn mysql_use_result on and
either fetch all rows or call finish before using another statement
handle).

        hp

-- 
   _  | Peter J. Holzer    | Am Anfang war der Bug und der
|_|_) | Sysadmin WSR       | Verantwortliche sprach:
| |   | [EMAIL PROTECTED]      | Es werde ein Testcase.
__/   | http://www.hjp.at/ |    -- Clemens Zauner in dcii

Attachment: pgpYvbP8srm2d.pgp
Description: PGP signature

Reply via email to