我想使用两次查询的结果。
如何重新定位指针以第二次从头开始读取结果?
下面的示例(为简单起见仅打印到屏幕上):
if ( $dbh = DBI->connect( "DBI:mysql:database=tng;host=ip", "username", "password" ) ) {
$strSQL = "select * from table";
if ( $strQuery = $dbh->prepare($strSQL) ) {
if ( $strQuery->execute() ) {
while ( @data = $strQuery->fetchrow_array() ) {
print $data[0];
}
--reposition to top and reread the query result and do something else with the data-- $strQuery->finish;
}
else {
$strMsg = "$strDateTime ERROR -- unable to execute statement: " . $strQuery->errstr . "\n";
print logFile "$strMsg";
}
}
else {
$strMsg = "$strDateTime ERROR -- unable to prepare statement: " . $dbh->errstr . "\n";
print logFile "$strMsg";
}
$dbh->disconnect();
}
else {
print logFile "$strDateTime ERROR -- unable to connect to iptables database ... " . DBI->errstr . " \n";
}