spewn
Programmer
- May 7, 2001
- 1,034
i have some code in a script i wrote, an example is located below.
never mind the names of tables and fields. they all work in my script, i've just changed them for easy reading.
my question is where do i need to put $dbh->disconnect(); and do i need to put $dbh->finish();?
i'm trying to set this up properly and not have open connections.
thanks!
- g
never mind the names of tables and fields. they all work in my script, i've just changed them for easy reading.
Code:
$sth = $dbh->prepare("select field1 from mytable1 where field5 = 'donuts'");
$sth->execute;
use constant SN1 => 0;
while (@row = $sth->fetchrow_array()){
$snackitem = $row[SN1];
}
if ($snackitem ne '1') {
$sth2 = $dbh->prepare("UPDATE members SET field4 = 'no' where field5 = 'donut'");
$sth2->execute;
}
$sth3 = $dbh->prepare("INSERT INTO mytable2 VALUES(0,'info','moreinfo')");
$sth3->execute;
$newID=$dbh->{q{mysql_insertid}};
$sth4 = $dbh->prepare("select f1 from mytable6 where f4 = '2/2/2009'");
$sth4->execute;
$count = $sth4->rows;
use constant AID => 0;
while (@row = $sth2->fetchrow_array() ){
$aidx = $row[AID];
}
if ($count eq 1) {
$sth5 = $dbh->prepare("UPDATE mtable SET clicks = '$newclicks' where f9 = '$afid'");
$sth3->execute;
}
else{
$sth5 = $dbh->prepare("INSERT INTO mtable VALUES(0,'')");
$sth5->execute;
}
my question is where do i need to put $dbh->disconnect(); and do i need to put $dbh->finish();?
i'm trying to set this up properly and not have open connections.
thanks!
- g