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 :-(

A simple yes or no will do.
Thanks,
B.


There is rarely such a thing as a simple yes or no.

You can do your example code above with most DBDs as far as I am aware. However, you should be aware that once you've executed a statement things change. Some databases do not support multiple "active" statements so you can do:

$sth1->prepare
$sth2->prepare
$sth3->prepare
$sth1->execute
  # do something with $sth1 until it is no longer active
  # e.g., fetch all rows from sth1
$sth3->execute
  # do something with $sth3 until it is no longer active

but you cannot do;

$sth1->prepare
$sth2->prepare
$sth3->prepare
$sth1->execute
  # sth1 still active e.g., if you have not fetched all rows
$sth3->execute # fails with some dbs since $sth1 is still active

Most databases and DBDs support multiple active statements but quite a few databases do not support MAS through their ODBC drivers.

Martin
--
Martin J. Evans
Easysoft Limited
http://www.easysoft.com

Reply via email to