I currently do two queries when using prepared statements. One to fetch the results and another to fetch the number of found rows. I could previously do this with one query with mysql_num_rows
. With larger queries i don't want to have to copy and paste the query and use COUNT every query. Is there a way to do this in one query like with mysql_num_rows
?
$connectdb->prepare("SELECT * FROM users WHERE username=:username");
$connectdb->prepare("SELECT COUNT(*) FROM users WHERE username=:username");
$query = $connectdb->execute(array(':username'=>$username));
$numrows = $query->fetchColumn();
if($numrows!=0) {
while(false !==($row = $query->fetch()))
{