. , , ,

,,,

Cold Fusion MS Windows WWW - — ,

5.1

5.2 Cold Fusion

5.3 Cold Fusion

5.4 Cold Fusion

5.5 DBML -

5.6 DBINSERT DBUPDATE

5.7

5.8 HTML -

5.9

5.10 DBML -

5.11
5.11.1 URL
5.11.2 CGI
5.11.3 DBSET
5.11.4HTTP Cookies
5.11.5

5.12
5.12.1
5.12.2 DBML

5.13
5.13.1 (DBIF & DBELSE)
5.13.2 URL (DBLOCATION & DBABORT)
5.13.3
5.13.4 MIME

5.14
5.14.1 SQL
5.14.2
5.14.3
5.14.4
5.14.5 SQL

" Cold Fusion User Guide " ( Cold Fusion).

5.1

Cold Fusion Allaire - , Web , :

HTML (Hyper-Text Markup Language) CGI (Common Gateway Interface) SQL (Structured Query Language) ODBC (Open Database Connectivity)

Cold Fusion Perl, C/C++, Visual Basic Delphi. , () HTML .

Cold Fusion 1.5 .

5.2 Cold Fusion

Cold Fusion CGI Web- Windows NT Windows 95 CGI.

Cold Fusion :

O'Reilly WebSite Microsoft Internet Server EMWAC HTTPS Process Software Purveyor Netscape Communications/Commerce Server Internet Factory Communications/Commerce Builder Spry Safety Web Server CSM Alibaba

Cold Fusion 32- ODBC - . Cold Fusion ODBC - :

32- . 1 ODBC API. SQL. /, .

Cold Fusion :

Windows NT 3.51( ) Windows 95. 80386 ; Pentium. 10Mb . 24Mb RAM Windows NT 16Mb Windows 95 TCP/IP. WWW .

Cold Fusion SETUP.EXE, 1.

, Cold Fusion, , Web CFPRO. :

, . -, HTML, Cold Fusion. , Cold Fusion.

Cold Fusion, , URL http://myserver/cfpro/getstart.htm, myserver - IP Web .

5.3 Cold Fusion

Cold Fusion . Cold Fusion :

Data Sources - ODBC, Cold Fusion. , "Add...", ODBC . "Setup...", . Cold Fusion , "Preferences..." , , . Templates - Cold Fusion. Debugging - . Mail - SMTP mail . 5.4 Cold Fusion

Cold Fusion HTML . Cold Fusion CGI - (DBML.EXE), Cold Fusion Engine , HTML , .

, DBML, . Cold Fusion :

DBQUERY - SQL - ; DBINSERT & DBUPDATE - ; DBOUTPUT - , HTML - .

, HTML - , HTML DBML:

HTML - , . , . DBML - , .

5-1 , Cold Fusion , :


5-1

"Submit" , Web - Web - . Web - , DBML - , Cold Fusion, . Cold Fusion DBML , , . Cold Fusion ODBC. Cold Fusion HTML - Web - . Cold Fusion SMTP - . Web - HTML - Web - . 5.5 DBML-

. URL, cookie.

URL, "&" () = . , , , 'user_id' 5 'example.dbm':

<A HREF="cgi-shl/dbml.exe?Template=example.dbm&user_id=5">

, , , . , :

<FORM ACTION="cgi-shl/dbml.exe?Template=example.dbm">
<INPUT TYPE="HIDDEN" NAME="user_id" VALUE="5">
<INPUT TYPE="SUBMIT" VALUE="Enter">
</FORM>

, CGI - DBML.EXE Template, .

, cookie CGI . cookie .5.11.

5.6 DBINSERT DBUPDATE

DBINSERT DBUPDATE , , POST.

DBINSERT, DBUPDATE. DATASOURCE TABLENAME. DATASOURCE ODBC, , TABLENAME - .

, ODBC 'Person DB', , - 'Person', DBINSERT :

<DBINSERT DATASOURCE="Person DB" TABLENAME="Person">

, , () . , , FORMFIELDS, , .

, , DBUPDATE , , HTML- .

DBINSERT DBUPDATE :

TABLEOWNER - (, SQL Server, Oracle .), , . TABLEQUALIFIER - . , SQL Server Oracle - , , Intersolv dBase - DBF .


HTML - :

<HTML>
<HEAD>
<TITLE> </TITLE>
</HEAD>
<BODY>
<FORM ACTION="/cgi-shl/dbml.exe?Template=example.dbm"
METHOD="POST">
: <INPUT TYPE="Text" NAME="FullName">
: <INPUT TYPE="Text" NAME="Phone">
: <INPUT TYPE="Text" NAME="Birthday">
</FORM>
</BODY>
</HTML>

, example.dbm, :

<DBINSERT DATASOURCE="Person DB" TableName="Persons"
FORMFIELDS="FullName,Phone,Birthday">
<HTML>
<HEAD><TITLE></TITLE></HEAD>
<BODY>
<H1> !</H1>
</BODY>
</HTML>

5.7

DBQUERY. :

<DBQUERY NAME=" "
DATASOURCE=" odbc"
SQL="sql " TIMEOUT=n MAXROWS=n DEBUG>

NAME , . ( ).

DATASOURCE ODBC, Cold Fusion.

DBQUERY, SQL, SQL ( , SQL ).

SQL , , SQL, . , SQL ODBC , Microsoft Query, Microsoft Office. Microsoft Query "/ SQL", SQL, ODBC, "...", "". SQL - , . SQL - "SQL" .

MAXROWS , .

TIMEOUT , . , ODBC - (, MS SQL Server 6.0).

DEBUG . , SQL - , .

'AllPersons', 'Persons' , ODBC 'Person DB':

<DBQUERY NAME="AllPersons" DATASOURCE="Person DB"
SQL="select * from Persons">

SQL - , . , , URL, CGI. , SQL - , "#" ( #Name#). Cold Fusion , , URL CGI. .

SQL -

1
URL

"/cgi-shl/dbml.exe?Template=prs.dbm&Id=22",

SQL DBQUERY

SQL="select * from Persons where Id = #Id#",

SQL - :

select * from Persons where Id = 22 .

2
, FirstLetters Persons , FullName . SQL :

SQL="select * from Persons
where FullName like '#FirstLetters#%'"

, , '%', , . , Id 1 , FullName - ( SQL , ).

, '%', SQL - . '_' (), .

5.8 HTML -

DBQUERY DBOUTPUT. , , , HTML, . , DBOUTPUT , , .

DBOUTPUT :

<DBOUTPUT QUERY=" " MAXROWS=n>
, HTML,
(.. #Name#)
</DBOUTPUT>

QUERY DBQUERY, , MAXROWS , DBOUTPUT.


'AllPersons', , , :

<DBOUTPUT QUERY="AllPersons" MAXROWS=50>
<HR>
#FullName# (: #Phone# ) <BR>
</DBOUTPUT>

:

<HR>
(: 222-22-22 ) <BR>
<HR>
(: 444-44-44 ) <BR>

5.9

DBTABLE DBCOL .

DBTABLE:

QUERY - DBQUERY, ;
MAXROWS - , ;
COLSPACING - , ( 2);
HEADERLINES - , ( 2);
HTMLTABLE - HTML - , HTML <PRE>.
BORDER - HTMLTABLE .

DBTABLE:

HEADER - , ;
WIDTH - ( 20);
ALIGN - (LEFT, RIGHT CENTER);
TEXT - , , , ., DBOUTPUT.

DBTABLE DBCOL:

<DBTABLE QUERY "AllPersons" MAXROWS=20>
<DBCOL HEADER=" " WIDTH="30" TEXT="#FullName#">
<DBCOL HEADER="" WIDTH="10" TEXT="#Phone#">
<DBCOL HEADER=" " WIDTH="9" TEXT="# DateFormat(Birthday)#">
</DBTABLE>

5.10 DBML - DBML, , (<!---), HTML (<!--). Cold Fusion , . (, HTML CGI ), DBML , , . '#' Cold Fusion, , DBOUTPUT, '#' . , , , SQL (. ). Cold Fusion , , DBOUTPUT. , SQL DBQUERY, . ,

SQL="select ""Full Name"" as FullName from Persons"

, , , , .

5.11 5.11.1 URL

, URL, , DBML , : #Form.Name#, #URL.Name#. , 'Form.' 'URL.' , , . .

5.11.2 CGI

CGI - . , , 'CGI.', #CGI.REMOTE_ADDR#.

5.11.3 DBSET

DBSET . , #UserId# 10.

<DBSET #UserId#=10>

DBSET, , ( ), , #CGI.SCRIPT_NAME#. , Variable, #Variable.UserId#.

5.11.4 HTTP Cookies

Cookies - , . Netscape Navigator, MS Internet Explorer 2.0, Web - .

Cookies. DBCOOKIE, :

<DBCOOKIE NAME="_" VALUE=" " EXPIRES=" " SECURE>

NAME VALUE . EXPIRES , . .. '10/09/97', (.. 10, 100), NOW ( ) NEVER. SECURE , SSL.

, cookies DBML, 'Cookies.', :

<DBOUTPUT>
#Cookies.User_Id#
</DBOUTPUT> .

5.11.5

, . , 'FindUser', , 'USER_ID', , , (.. #FindUser.UserId#).

, DBQUERY, , RecordCount CurrentRow, , DBOUTPUT, . (#FindUser.RecordCount#).

5.12 5.12.1

Cold Fusion . HIDDEN (), , , Cold Fusion , .

:

VALUE
_required .
_integer , , , .
_float , , , .
_range MIN = _
MAX = _
, .
_date , : DD/MM/YY, DD/MM/YYYY, DD/MM ( ). , , (.. DD-MM-YY).


, : FullName Birthday, HIDDEN .

: <INPUT TYPE="TEXT" NAME="FullName">
<INPUT TYPE="HIDDEN" NAME="FullName_required"
VALUE=" !">
: <INPUT TYPE="TEXT" NAME="Birthday">
<INPUT TYPE="HIDDEN" NAME="Birtday_date"
VALUE=" DD/MM/YYYY (, 20.08.1968)">

5.12.2 DBML

, , Cold Fusion . , , '#', , #DateFormat(Form.LastUpdate)#.

DateFormat '/' '' DD/MM/YY. 12/01/96
TimeFormat '/' HH:MI AM/PM.. 10:22 AM
NumberFormat , . 10,256
DecimalFormat , NumberFormat, . 10,256.3
DollarFormat , DecimalFormat, $ . $10,256.73
YesNoFormat Yes No. Yes, - No. Yes
ParagraphFormat TEXTAREA. , - HTML (<P>).
HTMLCodeFormat (>, <, ", &), HTML (<PRE>).
HTMLEditFormat , HTMLCodeFormat, <PRE>.

:

ParameterExists

, , Yes No. , UserId, :

<DBIF #ParameterExists(Form.UserId)# is Yes>

PreserveSingleQuotes

SQL , SQL. :

SELECT * FROM Persons WHERE
FullName Like '#PreserveSingleQuotes(Form.FullName)#%'

URLEncodedFormat

"+" - , URL.

IncrementValue DecrementValue

, . , 'OrderCount' :

<DBSET #OrderCount# = #IncrementValue(OrderCount)#

ValueList QuotedValueList

, , .

, , ValueList 11,22,33,44, QuotedValueList, , '11','22','33','44'.

IN , :

<DBQUERY NAME="Customers" ... ...>
<DBQUERY NAME="CustomerOrders" DATASOURCE="EXAMPLE"
SQL="SELECT * FROM Orders WHERE Customer_ID
IN ( #ValueList(Customer.CustomerID)# )">

5.13 5.13.1 (DBIF & DBELSE)

DBIF DBELSE, .

DBIF ( DBELSE ):

<DBIF >
HTML DBML
<DBELSE>
HTML DBML
</DBIF>

DBIF - "", Cold Fusion (, #Form.Name#, #CGI.User_Agent#), , ( ).

DBIF - "" :

is - , , True (), ; is not - is; Contains - , True, ; does not contain - contains; great then - , True, ; less then - , True, ; greater then or equal to - less then; less then or equal to - great then;


<DBIF #PersonSearch.RecordCount()# is 0>
<P>, ,
!
<DBELSE>
<DBOUTPUT QUERY="PersonSearch">
<HR>
: #FullName# <BR>
<DBIF #Phone# is "">
: #Phone# <BR>
<DBIF>
</DBOUTPUT>
</DBIF>

5.13.2 URL (DBLOCATION & DBABORT)

URL DBLOCATION. , , , URL, , . , :

<DBIF #NewPassword# is not #PasswordConfirmation#>
<DBLOCATION URL="/login/invalidpassword.htm">
</DBIF>

URL DBLOCATION , . , <DBLOCATION URL=#Page#>.

Cold Fusion DBABORT.

<P>
<DBABORT>
<P>

.

5.13.3

, Cold Fusion, . , Cold Fusion, , , . , DBINCLUDE.

DBINCLUDE , DBQUERY, DBOUTPUT DBTABLE. DBINCLUDE TEMPLATE . Cold Fusion ( , , , , URL CGI).

'test.dbm':

<DBINCLUDE TEMPLATE="test.dbm">

5.13.4 MIME

Cold Fusion MIME ( text/html). DBCONTENT, TYPE, , , . , VRML - :

<DBCONTENT TYPE="x-world/x-vrml">
<DBQUERY NAME="GetCyberRoom"
SQL="SELECT VRML_Script FROM CyberRooms WHERE
RoomNumber=#URL.RoomNumber#">
<DBOUTPUT QUERY="GetCyberRoom">
#VRML_Script#
</DBOUTPUT>

, Cold Fusion , DBOUTPUT.

5.14 5.14.1 SQL

, , , . Cold Fusion DBSQL, DBQUERY, SQL - , . DBSQL SQL, SQL - .


<DBQUERY NAME="SiteSearch" DATASOURCE="Sites Database"
SQL="SELECT * FROM SITES WHERE SiteType = #SiteType# ">
<DBIF #Form.City# is not "">
<DBSQL SQL=" AND City = '#Form.City#' ">
</DBIF>
<DBIF #Form.SortOrder# is not "">
<DBSQL SQL=" ORDER BY #Form.SortOrder# ">
</DBIF>
</DBQUERY>

5.14.2

DBTRANSACTION. , , . , , .

, :

<DBTRANSACTION>
<DBQUERY NAME="WithdrawCash" DATASOURCE="Bank Accounts"
SQL = "UPDATE Accounts SET Balance = Balance - #Amount#
WHERE Account_ID = #AccountFrom# ">
<DBQUERY NAME="DepositCash" DATASOURCE="Bank Accounts"
SQL = "UPDATE Accounts SET Balance = Balance + #Amount#
WHERE Account_ID = #AccountTo# ">
</DBTRANSACTION>

, ODBC . , Oracle, SQL Server Access , FoxPro, dBase Paradox - .

5.14.3

DBOUTPUT , . GROUP DBOUTPUT, DBOUTPUT. . DBOUTPUT , - .

:

<DBQUERY NAME="ListEmployees" DataSource="Employees"
SQL="SELECT * FROM Emp ORDER BY Department">
<DBOUTPUT QUERY="ListEmployees" GROUP="Department">
<P> <H2>#ListEmployees.Department#</H2>
<UL>
<DBOUTPUT>
<LI> #FullName# ##
</DBOUTPUT>
</UL>
</DBOUTPUT>

, , . ( DBOUTPUT ), SQL - (, ORDER BY Country, Region).

5.14.4

HTML - SELECT , (, checkbox), , , . IN SQL.


, :

<SELECT NAME="SelectedPersons" MULTIPLE SIZE="3">
<OPTION VALUE="1"> ..
<OPTION VALUE="2"> ..
<OPTION VALUE="3" SELECTED> ..
</SELECT>

, , SQL - :

SQL="SELECT * FROM Persons
WHERE Person_ID IN ( #SelectedPersons# )

, , IN, . Cold Fusion , HIDDEN . , :

<INPUT TYPE="HIDDEN" NAME="SelectedPersons" VALUE="-1">

5.14.5 SQL

DBOUTPUT, SELECT SQL, , , SQL - , :

INSERT - . UPDATE - . DELETE - .

SQL DBINSERT DBUPDATE . , , .



5.1 5.2 Cold Fusion 5.3 Cold Fusion 5.4 Cold Fusion 5.5 DBML - 5.6 DBINSERT DBUPDATE 5.7

 

 

 

! , , , .
. , :