📄 example1.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> lisa MANUAL: EXAMPLE 1 </TITLE>
<META NAME="Generator" CONTENT="myself">
<META NAME="Author" CONTENT="Gabriele Budelacci">
</HEAD>
<BODY STYLE="font-family:sans-serif;">
<H1><B><I>lisa</I></B> MANUAL: EXAMPLE 1</H1>
<BR>
Copyright © 2002, Gabriele Budelacci
<<A HREF="mailto:g.bude@eudoramail.com">g.bude@eudoramail.com</A>>
<BR>
<BR>
<small>Example 1 version 1.0.0 (2002-09-06)</small>
<BR>
<HR>
<BR>
Supposing you have a MySQL database called <I>testdb</I>, containing the following table:
<CENTER>
<BR>
<TABLE BORDER='2' CELLSPACING='0' CELLPADDING='0' BORDERCOLOR='Gray'>
<TR>
<TD>
<TABLE BORDER='0' CELLSPACING='0' CELLPADDING='2'>
<TR>
<TD ALIGN='Right'><B>Table name:</B></TD>
<TD>users</TD>
</TR>
<TR>
<TD ALIGN='Right'><B>Description:</B></TD>
<TD>Contains code (unique), firstname and lastname of many users</TD>
</TR>
<TR>
<TD ALIGN='Right'><B>Fields:</B></TD>
<TD>code, firstname, lastname</TD>
</TR>
<TR>
<TD ALIGN='Right'><B>Indexes:</B></TD>
<TD>code</TD>
</TR>
</TABLE>
</TD>
</TR>
</TABLE>
<BR>
</CENTER>
A simple <B><I>lisa</I></B> program for accessing this table is:
<CENTER>
<BR>
<TABLE BORDER='2' CELLSPACING='0' CELLPADDING='2' BORDERCOLOR='Gray'>
<TR>
<TD>
<PRE>
<FONT COLOR="Marroon"><%
<FONT COLOR="Blue">set</FONT> result;
result = <FONT COLOR="Red">dbQuery</FONT>( <FONT COLOR="Magenta">"SELECT code, firstname, lastname FROM users ORDER BY lastname, firstname;"</FONT> );
%></FONT>
<FONT COLOR="Marroon"><% <FONT COLOR="Green">// process the result only if it's not empty...</FONT> %></FONT>
<FONT COLOR="Marroon"><% <FONT COLOR="Blue">if</FONT> ( ! <FONT COLOR="Red">dbEmpty</FONT>( result ) ): %></FONT>
<TABLE BORDER='1'>
<TR>
<TD> <B> First Name </B> </TD>
<TD> <B> Last Name </B> </TD>
<TD> <B> Code </B> </TD>
</TR>
<FONT COLOR="Marroon"><% <FONT COLOR="Green">// for every result set, write a table row...</FONT> %></FONT>
<FONT COLOR="Marroon"><% <FONT COLOR="Blue">foreach</FONT> ( result <FONT COLOR="Blue">as</FONT> code, firstname, lastname ): %></FONT>
<TR>
<TD> <FONT COLOR="Marroon"><%= firstname %></FONT> </TD>
<TD> <FONT COLOR="Marroon"><%= lastname %></FONT> </TD>
<TD> <FONT COLOR="Marroon"><%= code %></FONT> </TD>
</TR>
<FONT COLOR="Marroon"><% <FONT COLOR="Blue">endforeach</FONT>; %></FONT>
</TABLE>
<FONT COLOR="Marroon"><% <FONT COLOR="Blue">endif</FONT>; %></FONT>
</PRE>
</TD>
</TR>
</TABLE>
<BR>
</CENTER>
The <B>config.xml</B> file shows like this:
<CENTER>
<BR>
<TABLE BORDER='2' CELLSPACING='0' CELLPADDING='0' BORDERCOLOR='Gray'>
<TR>
<TD>
<PRE>
<?xml version="1.0"?>
<database>
<db-type> <B>mySQL</B> </db-type>
<db-host> <B>mysqlhost.foo</B> </db-host>
<db-port> </db-port>
<db-name> <B>testdb</B> </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>
</PRE>
</TD>
</TR>
</TABLE>
<BR>
</CENTER>
The <B>config.xml</B> file must be placed in the same directory containing the source code of this example.<BR>
Once you're entered this directory, you can compile the example by typing:
<blockquote style="background-color:#CDCDCD;">
<B>lisac</B> --php <I>example1.lisa</I><BR>
</blockquote>
This will compile the <B>example1.lisa</B> source file to the <B>example1.php</B> file.<BR>
The <B>dbsupport.php</B> file will be created using the infos specifieds in the <B>config.xml</B> file.<BR>
<BR>
Once you have installed <B><I>lisa</I></B> distribution, you may have entered the <B>modules</B> directory
and compiled the <B>std.lisa</B> source, generating the <B>std</B> module:
<blockquote style="background-color:#CDCDCD;">
<B>lisac</B> --module --php <I>std.lisa</I><BR>
</blockquote>
Last, you must copy all the <B>.php</B> generated files into a public web directory and test the page.<BR>
<BR>
The page may show like this:<BR>
<BR>
<CENTER><IMG SRC="example1/example1.gif" BORDER=0 ALT="example 1 page"></CENTER>
<BR>
<HR>
<H2>LEGAL</H2>
Copyright © 2002 Gabriele Budelacci <<A HREF="mailto:g.bude@eudoramail.com">g.bude@eudoramail.com</A>><BR>
<BR>
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.<BR>
<BR>
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.<BR>
<BR>
If you use this software in a commercial distribution, it would be nice to send the authors a complimentary copy of your product.<BR>
<BR>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -