If I prepare a statement handle, bind parameter(s), execute, and then go into a loop, can I bind_param again within the loop prior to execution? Here's what I mean:
$sth->bind_param(1, $var, { TYPE => SQL_INTEGER });
$sth->execute;
while ( @row = $sth->fetchrow_array ) {
$var2 = $row[0];
}
while ($ctl == 0) {
*** do stuff ***
$sth->bind_param(1, $var2, { TYPE => SQL_INTEGER });
$sth->execute;
while ( @row = $sth->fetchrow_array ) {
$var2 = $row[0];
}
*** do stuff ***
}Hope that helps - my question is whether the bind_param that occurs inside the while ($ctl == 0) loop actually works, or will the executed statement handle always return data based on the bind_param that took place outside the loop?
The database is mySQL.
Code:
$sth = $dbh->prepare( "SELECT field1 FROM table WHERE primary_key_field = ? "); $sth->bind_param(1, $var, { TYPE => SQL_INTEGER });
$sth->execute;
while ( @row = $sth->fetchrow_array ) {
$var2 = $row[0];
}
while ($ctl == 0) {
*** do stuff ***
$sth->bind_param(1, $var2, { TYPE => SQL_INTEGER });
$sth->execute;
while ( @row = $sth->fetchrow_array ) {
$var2 = $row[0];
}
*** do stuff ***
}
The database is mySQL.

