I've got a problem
with a site that was built by someone else using Dreamweaver MX. The site
has since been converted from Access to SQL server. Some of the queries
need to be changed. The problem is that the SQL statements are being
created by MM predefined functions. I don't know how to edit these through
Dreamweaver. I've has a look at the code involved and it quite complicated
(having to be versatile enough to handle all events). What I'm after
is a way to edit this through the WYSIWYG dreamweaver interface rather then me
changing the code. I have posted most of the code below to give you an
idea of what is being created.
Thanks
<cfscript>
// *** Update Record: set variables
// *** Update Record: set variables
If
(IsDefined("MM_update") AND IsDefined("MM_recordId")) {
MM_editDatasource = #MM_conStudent_DSN#;
MM_editUserName = #MM_conStudent_USERNAME#;
MM_editPassword = #MM_conStudent_PASSWORD#;
MM_editTable = "Admin";
MM_editColumn = "AdminID";
MM_recordId = "" & MM_recordId & "";
MM_editRedirectUrl = "AdminUpdate.cfm";
MM_fieldsStr = "FirstName|value|LastName|value|Email|value|Password|value|SecretQuestion|value|SecretAnswer|value|RegistrationDate|value|Active|value";
MM_columnsStr = "FirstName|',none,''|LastName|',none,''|Email|',none,''|Password|',none,''|SecretQuestion|',none,''|SecretAnswer|',none,''|RegistrationDate|',none,NULL|Active|none,1,0";
MM_editUserName = #MM_conStudent_USERNAME#;
MM_editPassword = #MM_conStudent_PASSWORD#;
MM_editTable = "Admin";
MM_editColumn = "AdminID";
MM_recordId = "" & MM_recordId & "";
MM_editRedirectUrl = "AdminUpdate.cfm";
MM_fieldsStr = "FirstName|value|LastName|value|Email|value|Password|value|SecretQuestion|value|SecretAnswer|value|RegistrationDate|value|Active|value";
MM_columnsStr = "FirstName|',none,''|LastName|',none,''|Email|',none,''|Password|',none,''|SecretQuestion|',none,''|SecretAnswer|',none,''|RegistrationDate|',none,NULL|Active|none,1,0";
// create the
MM_fields and MM_columns arrays
MM_fields = ListToArray(MM_fieldsStr,"|");
MM_columns = ListToArray(MM_columnsStr,"|");
// set the form values
For (i=1; i+1 LE ArrayLen(MM_fields); i=i+2) {
MM_fields[i+1] = IIf(IsDefined(MM_fields[i]),"FORM." & MM_fields[i],DE(""));
}
MM_fields = ListToArray(MM_fieldsStr,"|");
MM_columns = ListToArray(MM_columnsStr,"|");
// set the form values
For (i=1; i+1 LE ArrayLen(MM_fields); i=i+2) {
MM_fields[i+1] = IIf(IsDefined(MM_fields[i]),"FORM." & MM_fields[i],DE(""));
}
// append the
query string to the redirect URL
If (MM_editRedirectUrl NEQ "" AND CGI.QUERY_STRING NEQ "") {
If (Find("?", MM_editRedirectUrl) EQ 0) {
MM_editRedirectUrl = MM_editRedirectUrl & "?" & CGI.QUERY_STRING;
} Else {
MM_editRedirectUrl = MM_editRedirectUrl & "&" & CGI.QUERY_STRING;
}
}
}
</cfscript>
<cfscript>
// *** Update Record: construct a sql update statement and execute it
If (MM_editRedirectUrl NEQ "" AND CGI.QUERY_STRING NEQ "") {
If (Find("?", MM_editRedirectUrl) EQ 0) {
MM_editRedirectUrl = MM_editRedirectUrl & "?" & CGI.QUERY_STRING;
} Else {
MM_editRedirectUrl = MM_editRedirectUrl & "&" & CGI.QUERY_STRING;
}
}
}
</cfscript>
<cfscript>
// *** Update Record: construct a sql update statement and execute it
If
(IsDefined("MM_update") AND IsDefined("MM_recordId")) {
// create the
update sql statement
MM_editQuery = "update " & MM_editTable & " set ";
For (i=1; i+1 LE ArrayLen(MM_fields); i=i+2) {
FormVal = MM_fields[i+1];
MM_typesArray = ListToArray(MM_columns[i+1],",");
Delim = IIf(MM_typesArray[1] NEQ "none","MM_typesArray[1]",DE(""));
AltVal = IIf(MM_typesArray[2] NEQ "none","MM_typesArray[2]",DE(""));
EmptyVal = IIf(MM_typesArray[3] NEQ "none","MM_typesArray[3]",DE(""));
If (FormVal EQ "") {
FormVal = EmptyVal;
} Else {
If (AltVal NEQ "") {
FormVal = AltVal;
} Else If (Delim EQ "'") { // escape quotes
FormVal = "'" & Replace(FormVal,"'","''","ALL") & "'";
} Else {
FormVal = Delim & FormVal & Delim;
}
}
If (i GT 1) MM_editQuery = MM_editQuery & ",";
MM_editQuery = MM_editQuery & MM_columns[i] & " = " & FormVal;
}
MM_editQuery = MM_editQuery & " where " & MM_editColumn & " = " & MM_recordId;
}
</cfscript>
<cfif Not #MM_abortEdit# AND IsDefined("MM_update") AND IsDefined("MM_recordId")>
<cfquery name="MM_editCmd" datasource=#MM_editDatasource# username=#MM_editUserName# password=#MM_editPassword#>
#PreserveSingleQuotes(MM_editQuery)#
</cfquery>
MM_editQuery = "update " & MM_editTable & " set ";
For (i=1; i+1 LE ArrayLen(MM_fields); i=i+2) {
FormVal = MM_fields[i+1];
MM_typesArray = ListToArray(MM_columns[i+1],",");
Delim = IIf(MM_typesArray[1] NEQ "none","MM_typesArray[1]",DE(""));
AltVal = IIf(MM_typesArray[2] NEQ "none","MM_typesArray[2]",DE(""));
EmptyVal = IIf(MM_typesArray[3] NEQ "none","MM_typesArray[3]",DE(""));
If (FormVal EQ "") {
FormVal = EmptyVal;
} Else {
If (AltVal NEQ "") {
FormVal = AltVal;
} Else If (Delim EQ "'") { // escape quotes
FormVal = "'" & Replace(FormVal,"'","''","ALL") & "'";
} Else {
FormVal = Delim & FormVal & Delim;
}
}
If (i GT 1) MM_editQuery = MM_editQuery & ",";
MM_editQuery = MM_editQuery & MM_columns[i] & " = " & FormVal;
}
MM_editQuery = MM_editQuery & " where " & MM_editColumn & " = " & MM_recordId;
}
</cfscript>
<cfif Not #MM_abortEdit# AND IsDefined("MM_update") AND IsDefined("MM_recordId")>
<cfquery name="MM_editCmd" datasource=#MM_editDatasource# username=#MM_editUserName# password=#MM_editPassword#>
#PreserveSingleQuotes(MM_editQuery)#
</cfquery>
Brian Knott
Senior Database
Developer
QANTM
Studio
Phone (07) 3017
4331
Mobile 0407
572127
Email
[EMAIL PROTECTED]
Website
<http://www.qantm.com.au/>
This email is sent commercial-in-confidence. The contents of this email and attachments are intended for the addressee only and may be subject to the laws of copyright, confidential information and privacy. You may only forward it on or otherwise copy or use it with the consent of the sender.
You are currently subscribed to cfaussie as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]
MX Downunder AsiaPac DevCon - http://mxdu.com/
