Split search_db() into build_query_sensitive()

build_query_sensitive will build the SQL query if it's sensitive or not. It will then call upon search_db() to run the query.