Nightly Build

In the process of working on the Galleon ports I noticed that the sql library's subqueries feature wasn't working in update statements, so I resolved that and while I was at it, I added character masking to the form tools numeric validation so that when javascript is enabled, users won't be able to enter non-numeric characters into text fields that have numeric validation.

Here's a sample of how to use the sql update:

<cfscript>
ds = request.tapi.getObject("datasource").init();

ins = { hitcount = ds.getStatement("select").init("mytable","hitcount + 1") };
ins.hitcount.filter("primarykey","keyvalue","=");
update = ds.getStatement("update").init("mytable",ins);

update.setFirstFilter(ins.hitcount.getFirstFilter());

update.execute();
</cfscript>

I declared ins using ColdFusion 8's implicit structure syntax for convenience sake, since the update statement is initialized with the name of the table and a structure with the values you want to insert into the record. That 2nd to last line reuses the filter object from the select statement so that both the select and the update have the same filters - plus not having to instantiate another object is more efficient.

Comments
BlogCFC was created by Raymond Camden. This blog is running version 5.5.006. | Protected by Akismet | Blog with WordPress