Chapter 2. Basics: Getting Started

Table of Contents

Outline
A First WACS Program
Modules: Importing
Configuration And Security
Initialising Database Connection
Fetching Some Records
Showing The Results
Finishing Off
Putting It All Together
Running MySimple
Reviewing The First Program

Outline

In this chapter we're going to talk about the basic first steps in making use of the WACS API from your own programs. We're going to assume that you've got a WACS server you can use up and running; that you know where things are on it and that you have appropriate write access to the web document tree (if you're working in PHP) or the cgi-bin directory (if you're working in Perl). Hopefully you'll have both some models and a few image sets known in the WACS system to work with. For these first code examples, you could merely load the sample model profiles we've provided in the samples directory of the WACS distribution.

While the finished code of the sample programs featured here is available in the samples directory of the WACS Core distribution (for the Perl verion) or the WACS-php distribution (for the PHP5 version), you may wish to type it in as you go along as an aid to learning how to use the interface. If you do, we'd recommend calling this file mysimple for perl, or mysimple.php for PHP. For consistency, we're going to put the PHP dialect first and then the Perl dialect in each of the examples.

The basic structure of your first WACS application will consist of five steps; these are:

  1. import the WACS API modules

  2. read configuration and check access rights

  3. initialise the database connection

  4. run an appropriate database query

  5. retrieve records and display them