How can I easily get the number of rows returned with "SELECT *
" SQL-query?
function valid_credentials($db,$name,$pw) {
try {
$sth = $db->prepare("SELECT * FROM ib_members WHERE name=:val AND pw=:val2");
$sth->bindValue(":val",$name);
$sth->bindValue(":val2",$pw);
$sth->execute();
$numrows = $sth->fetchColumn();
return $numrows;
} catch (PDOException $e) {
return $e->getMessage();
}
}
That returns 14, which is definately not the number of rows returned, but it's the ID that the first row has.