lisa MANUAL: EXAMPLE 1


Copyright © 2002, Gabriele Budelacci <g.bude@eudoramail.com>

Example 1 version 1.0.0 (2002-09-06)


Supposing you have a MySQL database called testdb, containing the following table:

Table name: users
Description: Contains code (unique), firstname and lastname of many users
Fields: code, firstname, lastname
Indexes: code

A simple lisa program for accessing this table is:

<%
set result;
result = dbQuery( "SELECT code, firstname, lastname FROM users ORDER BY lastname, firstname;" );
%>
<% // process the result only if it's not empty... %>
<% if ( ! dbEmpty( result ) ): %>
	<TABLE BORDER='1'>
	<TR>
		<TD> <B> First Name </B> </TD>
		<TD> <B> Last Name </B> </TD>
		<TD> <B> Code </B> </TD>
	</TR>
	<% // for every result set, write a table row... %>
	<% foreach ( result as code, firstname, lastname ): %>
		<TR>
			<TD> <%= firstname %> </TD>
			<TD> <%= lastname %> </TD>
			<TD> <%= code %> </TD>
		</TR>
	<% endforeach; %>
	</TABLE>
<% endif; %>

The config.xml file shows like this:

<?xml version="1.0"?>
<database>
    <db-type> mySQL </db-type>
    <db-host> mysqlhost.foo </db-host>
    <db-port>  </db-port>
    <db-name> testdb </db-name>
    <db-dsn>  </db-dsn>
    <jdbc>
        <jdbc-driver>  </jdbc-driver>
        <jdbc-string>  </jdbc-string>
    </jdbc>
    <db-username>  </db-username>
    <db-password>  </db-password>
</database>

The config.xml file must be placed in the same directory containing the source code of this example.
Once you're entered this directory, you can compile the example by typing:
lisac --php example1.lisa
This will compile the example1.lisa source file to the example1.php file.
The dbsupport.php file will be created using the infos specifieds in the config.xml file.

Once you have installed lisa distribution, you may have entered the modules directory and compiled the std.lisa source, generating the std module:
lisac --module --php std.lisa
Last, you must copy all the .php generated files into a public web directory and test the page.

The page may show like this:

example 1 page


LEGAL

Copyright © 2002 Gabriele Budelacci <g.bude@eudoramail.com>

This example/tutorial is free documentation; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free software Foundation; either version 2 of the license, or (at your option) any later version.

This software is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. See the GNU General Public License for more details. You can obtain a copy of the GNU General Public License by writing to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

If you use this software in a commercial distribution, it would be nice to send the authors a complimentary copy of your product.