For some reason my PDO statement keeps returning NULL when it should return an integer. I've tried to directly input the query into my DB editor (HeidiSQL) and it works fine.
Here's the code:
private function subscribe_moeder(){
$email = $this -> args["email"];
if(!filter_var($email, FILTER_VALIDATE_EMAIL))return $this -> errors[] = "Invalid email \n";
# /# $Query = "SELECT * FROM subscribers WHERE email = :email";
# /## $core = Core::getInstance();
# /###
# This works +####
# \### $res = $core -> db -> prepare($Query);
# \## $res -> bindParam(":email", $email);
# \# $res -> execute();
if($found = $res -> fetch(PDO::FETCH_OBJ)){
# /# $Query = "SELECT (SELECT id FROM subscriber_binaries WHERE name='møder') &
# /## (SELECT attribute FROM subscribers WHERE email=:email) as s";
# /###
# This doesn't +#### $res = $core -> db -> prepare($Query);
# \### $res -> bindParam(":email", $email);
# \## $res -> execute();
# \# $s = $res -> fetch( PDO::FETCH_OBJ );
if($s -> s != 0){
$this -> response = 'Already subscribed';
} else {
$this -> response = $s->s;
}
}
}