I have a page which needs to check for results, and the way I came up with to do it is successful, but iterates through the first row of results. Is there a way I can check without iterating, or to go back to that first row without executing the query again?
I was doing this:
$q = pdo::prepare($SQL);
$q->execute(array(':foo'=> foo, 'bar'=>bar);
if(!q->fetch){
//no results;
}else{
//results;
};
It does pretty much exactly what I hoped, with the unfortunate side affect of skipping the first row of results.
I've resorted to running $q->execute() a second time. Is there a way to avoid doing this?