I don't know how to use pdo with mysqli, but what you want to do is check if the record exists using mysql EXISTS and get the result (which is always 1 or 0).
SELECT EXISTS(SELECT 1 FROM ".USER_TABLE." WHERE email = ?) as email_exists
In the above request, email_exists will be either 1 or 0, depending on whether the mail is in the table or not.
With PDO I would do it like this:
$sth = $dbh->prepare("SELECT EXISTS(SELECT 1 FROM ".USER_TABLE." WHERE email = :email)"); $sth->execute(array('email' => $email)); return $sth->fetchColumn();
I will let you know how to do it yourself with your own class.
source share