CFXM 7 Hosting

8 March 2007 11:10 (EST)
HostingFuse Optima — AU$99/year (see details)
CrystalTech — US $16.95/month

Looping dates and times

8 March 2007 11:09 (EST)
<cfset startDate = Now()>
<cfset backDate = DateAdd("yyyy",-6,startDate)>
How Far Back do you want to go:
<select name="goBack">
<cfloop condition="startDate gt backDate">
<cfoutput><option>#DateFormat(startDate,"mm/dd/yyyy")#</option></cfoutput>
<cfset startDate = DateAdd("yyyy",-1,startDate)>
</cfloop>
</select>
<hr>
10 Day Loop<br>
<cfloop from="#Now()#" to="#DateAdd("d",9,Now())#" index="i">
<cfoutput>#DateFormat(i,"mm/dd/yyyy")#<br></cfoutput>
</cfloop>
<hr>
Days left to the end of the month:<br>
<cfloop from="#now()#"
to="#DateAdd("d",DaysInMonth(now()) - DatePart("d",now()),now())#"
index="i" step="#CreateTimeSpan(0,23,59,59)#">

<cfoutput>#DateFormat(i,"mm/dd/yyyy")#<br></cfoutput>
</cfloop>
<hr>
Time Loop<br>
<cfset startTime = CreateTime(0,0,0)>
<cfset endTime = CreateTime(23,59,59)>
<cfloop from="#startTime#" to="#endTime#" index="i"
step="#CreateTimeSpan(0,0,30,0)#">

<cfoutput>#TimeFormat(i, "hh:mm tt")#<br /></cfoutput>
</cfloop>

Display datasources

8 March 2007 11:08 (EST)
<cfif left(server.ColdFusion.ProductVersion,1) le "5">
<cfregistry action="getall" name="DataSources" type="any" sort="entry"
branch="HKEY_LOCAL_MACHINE\SOFTWARE\allaire\coldfusion\currentversion\data-sources">

<cfoutput query="datasources">#datasources.entry#<br></cfoutput>
<cfelseif left(server.ColdFusion.ProductVersion,1) ge "6">
<cffile action="read" file="#server.coldfusion.rootdir#\lib\neo-query.xml" variable="thisxml">
<cfwddx action="wddx2cfml" input="#variables.thisxml#" output="aDsnInfo">
<cfset ldsn = "">
<cfloop collection="#aDsnInfo[3]#" item="thisdsn">
<cfset stInfo = aDsnInfo[3]>
<cfset stInfo = stInfo[thisdsn]>
<cfif stInfo.driver is "MSSQLServer" or stInfo.driver is "MSAccess" or stInfo.driver is "MSAccessJet">
<cfset ldsn = listappend(ldsn,variables.thisdsn)>
</cfif>
</cfloop>
<cfset ldsn = listsort(ldsn,"TextNoCase")>
<cfloop list="#ldsn#" index="thisdsn">
<cfoutput>#variables.thisdsn#<br></cfoutput>
</cfloop>
</cfif>

Flushing cached queries

8 March 2007 11:07 (EST)
<cflock name="serviceFactory" type="exclusive" timeout="10">
<cfscript>
factory = CreateObject("java", "coldfusion.server.ServiceFactory");
ds_service = factory.datasourceservice;
ds_service.purgeQueryCache();
</cfscript>
</cflock>

List MX Datasources

8 March 2007 02:01 (EST)
<cfobject component="cfide.administrator.components.administrator" name="admin">
<cfset admin.login("MY_SECRET_ADMIN_PSWD")>
<cfobject component="cfide.administrator.components.datasource" name="ds">
<cfdump var="#ds.getdatasource()#">
<cfset admin.loginout()>

Cool tip

8 March 2007 02:00 (EST)
Using a server on which you have access to CFIDE and the Aministrator password, add /CFIDE/componentutils/componentdoc.cfm to the URL, enter the CF Administrator password and prepare to be utterly amazed.

Faster SQL Deletes

8 March 2007 02:00 (EST)
Want to delete all data in a table? You can use DELETE FROM TABLE, but that is slow because changes are logged. A faster solution is to issue a TRUNCATE TABLE command which is faster because no logging occurs (and if really intent to delete all the data in a table, logging is probably not that important).

How To Access Badly Named Form Fields

8 March 2007 01:58 (EST)
Sometimes you need to process the results of a form which was made up of fields named with invalid characters (one was "first name"). Trying to access the field as #FORM.first name# won't work and will throw an error. So how to access these fields?

The answer is to remember that FORM is not just a prefix, it is also a structure. Structure members can be accessed as #structure.member# and as #structure["member"]#. And that latter format will allow access to badly named form fields (as the name is enclosed in quotes). So, the solution is to use #FORM["first name"]#.

Faster Dreamweaver Loading

8 March 2007 01:57 (EST)
Here's another tip to improve Dreamweaver load time. In Preferences select the File Types / Editors screen and add .cfm and .cfc to the Open in Code View list. You'll lose support for design view and the Insert bar, but the load speed will be much faster.

Why is the CFIDE directory called CFIDE?

8 March 2007 01:57 (EST)
Back before Allaire acquired the Homesite product from Nick Bradbury, a fully web-based ColdFusion administration AND development experience was envisioned. It was to use a combination of client-side Java and ColdFusion server-side code. The "/CFIDE" (or "ColdFusion Integrated Development Environment") directory was the designated location for this administrator and development environment.
Pages   ← previous   next
1 2 3 4 5