HOWTO: Canned Queries

General Overview

Canned queries are queries that tend to be quite common and are stored in such a way that they can be easily executed without having to re-enter the details of the query each time. For example, if you had a database with softball team stats in it, you could create canned queries for each team in the database so that a user would only have to click on a link to "Blue Team Stats" in order to bring up all of the data stored about the Green Team.

Creating a Canned Query

The best way to make a canned query is to copy the link marked "Perma-link to this page" which appears at the bottom of every search result page. Perform a search and sort, etc. as you want the canned query to be. Then copy the permalink and modify any parameters as you want.

Creating a canned query in mySiteMaker simply consists of creating a special type of URL, called an HTTP GET, and embedding it into a web page. Before getting into the details of exactly what all the options are for this URL, let's look at an example:

http://www.myserver.com/cgi-bin/mySiteMaker/general_search.cgi?conf_file_name=myDB_myTable.conf&column=name&order_column=color

or you can make the link relative if the server that is hosting the page is the same as the server running mySiteMaker:

/cgi-bin/mySiteMaker/general_search.cgi?conf_file_name=myDB_myTable.conf&column=name&order_column=color

If you are not using a relative URL (the first example), then the URL has four distinct parts (relative URLs only have the last three parts):

  1. The HTTP request to the server: http://www.myserver.com
  2. The path, on the server, from the root CGI-BIN directory to the file "general_search.cgi": /cgi-bin/mySiteMaker/general_search.cgi
  3. A question mark: ? that indicates that this is a GET type URL. This tells the server that the parameters that we are passing to the CGI script are going to be included in the URL.
  4. A string of parameter names and values that tell "general_search.cgi" information about the kind of search it is to perform. conf_file_name=myDB_myTable.conf&column=name&order_column=color... Notice how there is an equal symbols (=) between parameter names and their values and there are ampersand (&) characters between each parameter/value pair.

Building your canned query simply means taking the 4 (or 3) parts mentioned above and putting them together, taking care to include all of the required parameters and adding optional ones as you see fit.

To get an RSS feed, use the permalink as outlined above, and tack on &out_type=rss on the end.