Checking if a record exists in a table (translated from typical mysql)

Now done with normal mysql:

/*     email    */
protected function checkEmail()
{
    $query = mysql_query("SELECT `email` FROM `mytable` WHERE (`email`='$this->email')");
    if (!$result = mysql_fetch_array($query)){
        //    email    TRUE,    
        return TRUE;
    }
    else
    {
        //    email,   FALSE
        return FALSE;
    }
}

How to do this in MySQLi?


Answer 1, authority 100%

I’ll answer myself.

/*     email    */
public function checkEmail()
{
    if ($result = $this->mysqli->prepare('SELECT `email` FROM `league` WHERE `email`=? LIMIT 1'))
    {
        $result->bind_param("s",$this->email);
        $result->execute();
        $result->store_result();
    $rows = $result->num_rows;
    /* close statement */
    $result->close();
    if (!$rows)
    {
        //    email    TRUE,    
        return TRUE;    
    }
    else
    {
        //    email,   FALSE
        return FALSE;
    }
}

}