The above (EDIT: due to slow typing, above menas 2 posts above) is correct insofar connection goes, and the general idea applies to statements as well. Executing the same query as a prepared statement several times using different parameters is quicker than multiple non prepared queries or creating new prepared statements from the same SQL statement several times.
Keep the statement around for as long as you need it, then close it. If using more than one prepared statement, use $stmt->free_result() before executing/using another statement, if you want to execute the first one later on again. If not, you can just as well free it directly.
But, you can easily do the equivalent of this
arrSample = RS.GetRows()
in php
$arr = array();
# assuming bind params has been called
while ($stmtname->fetch())
{
$arr[] = array('field1' => $field1, 'field2' => $field2);
}
printf('<pre>%s</pre>', print_r($arr,1));
Or, if you use a database abstraction layer like PDO or MDB2, you can fetch all row at once
$db = new PDO(...);
$stmt = $db->prepare(...);
$stmt->execute(...);
$arr = $stmt->fetchAll();