'if'语句条件代码未按预期运行

I genuinely do not understand how this code is messing up but it just is, I've never ran into anything of the sort so if anyone can explain what is going on i'd be very glad.

The code : $functions->update("batzz",$functions->getPlayerInfo("batzz")); runs no matter whether the if condition is met or not, which is starting to get very frustrating.

This is the whole excerpt of code. There is no loop around it, and when it runs, it prints the proper statement but regardless of whether the if is true or false, it runs the update function.

if($functions->checkRecordsExist($_GET['name']) == false) {
    $functions->update("batzz",$functions->getPlayerInfo("batzz"));
    echo "Your account has been updated! Visit your page <a href='/osrstracker/name/". $_GET['name'] ."'>here</a>";
} else {
    echo "Oops, either you havess already updated your account within the past 12 hours or we have messed something up!";
}

I would love to understand how this possibly could happen, and if I can fix it as it is very annoying!

Code for function : $functions->checkRecordsExist($_GET['name']) == false

public function checkRecordsExist($dpname){
        $curdate = date("Y-m-d H:i:s");
        $olddate = date('Y-m-d H:i:s', strtotime('-12 hour'));
        $this->query("SELECT * FROM stats JOIN accounts ON stats.userid = accounts.id  WHERE accounts.displayName=:dpname AND stats.date BETWEEN '$olddate' AND '$curdate';");
        $this->bind(":dpname",$dpname);
        $result = $this->resultSet();

        if(!empty($result)){
            if($result[0]['rank'] == 1){
                $this->query("SELECT * FROM stats JOIN accounts ON stats.userid = accounts.id  WHERE accounts.displayName=:dpname AND stats.date BETWEEN '$olddate' AND '$curdate';");
                $this->bind(":dpname",$dpname);
                $result2 = $this->resultSet();
                if(empty($result2)){
                    return false;
                }

            }
            return true;
        }
        return false;
    }

PDO Object after query being prepared

object(PDOStatement)#3 (1) {
  ["queryString"]=>
  string(171) "SELECT * FROM stats JOIN accounts ON stats.userid = accounts.id  WHERE accounts.displayName=:dpname AND stats.date BETWEEN '2016-03-19 11:48:36' AND '2016-03-19 23:48:36';"
}

Because you are using == and not === I would wager that you are actually getting a null, empty string or 0 back from that function - something that is equivalent to false but is not a boolean. If you were to use a "=== false" comparison or reverse order and do a "!== false" "or === true" comparison, that will force check the type to boolean and may solve your problem.

May not be an answer but too much for a comment. I believe the problem is here:

$result = $this->resultSet();

if(!empty($result)){
    if($result[0]['rank'] == 1){

I'm thinking that $result[0]['rank'] is never 1 so you are hitting the return true after the second if statement.

I suggest checking the result and maybe even re-writing the logic like so:

// no result means false.
if (empty($result)){
    return false;
}

// if the result is NOT a match return true (is this correct?)
if ($result[0]['rank'] != 1){
    return true;
}

// must be a matched result, check for a second result
$this->query("SELECT * FROM stats JOIN accounts 
    ON stats.userid = accounts.id
    WHERE accounts.displayName=:dpname AND stats.date 
    BETWEEN '$olddate' AND '$curdate';");
$this->bind(":dpname",$dpname);
$result2 = $this->resultSet();

// invert result of empty() as final return value (is this correct?)
return (! empty($result2));