Extracted methods for long if conditions in the sql.php