I an having a tough time with this and trying to either return 1 or true if my select statement finds a record. I am working with MSSQL Server and PHP with PDO because of its safety. I know that fetchColumn() is not the right statement to use, but that's where I gave up because I tried almost everything else.
Here is my code.
public function activate($email, $email_code) {
$query = $this->db->prepare("SELECT * FROM users WHERE (email = ? AND email_code = ? AND confirmed = ?)");
$query->bindValue(1, $email);
$query->bindValue(2, $email_code);
$query->bindValue(3, 0);
try{
$query->execute();
$rows = $query->fetchColumn();// HERE I AM NOT SURE WHAT TO USE ??? HELP!
if($rows == 1){
$query_2 = $this->db->prepare("UPDATE users SET confirmed =? WHERE email = ?");
$query_2->bindValue(1, 1);
$query_2->bindValue(2, $email);
$query_2->execute();
return true;
}else{
return false;
}
}
catch(PDOException $e){
die($e->getMessage());
}
}