/** * Checks whether an email exists in the database * @param $email string The email whose existence to check * @return bool Whether the email exists in the database or not */ public static function email_exists($email) { // the user row with the particular email; it could be empty $user_row = User::get_user_row_by_email($email); // return false if the user row is null return empty($user_row) ? false : true; }
/** * Gets the user row from the database. */ private function get_user_row() { // Return out of the function if the user row is set if (isset($this->user_row)) { return; } else { // get the user row by the email $user_row = User::get_user_row_by_email($this->email); $this->user_row = $user_row; } }