ColdFusion: cfquery and the SQL insert statements

Written on 12 March 2011, 01:09pm

Tagged with: , ,

Say you have a cfquery statement which does a simple insert in a table in your database:

<cfquery name="query_name" result="result_name">
INSERT INTO mytable(id,name) VALUES(1,'foo')

This post presents two very useful and least documented features of the cfquery tag.

1. How to get the newly inserted ID

The ColdFusion 9 documentation offers several solutions depending on your database:

3 things you probably did not know about cfcache

Written on 8 March 2011, 12:03am

Tagged with: ,

Note, February 17th 2014: this post was written on March 8th 2011, but I forgot to publish it. So here it is, almost 3 years later 🙂

I recently had to work with cfcache in ColdFusion 9 and I found a few interesting things. Two of them deal about the backwards compliance in ColdFusion 9, while the third is about caching page fragments.

  1. cfcache default action
    The default action of the cfcache tag changed from ColdFusion 8 to ColdFusion 9:

    • in ColdFusion 8, default action is cache (server-side and client-side caching)
    • in ColdFusion 9, default action is serverCache (server-side caching only)
  2. using cfcache to cache pages with URL parameters
    I found this one while reading the ColdFusion 9 book, volume 2.

  3. caching page fragments: ColdFusion stores the cfcache tag line number as part of the ID for the cached item.
    This one is a little bit more complicated and I found it on the Rob Brooks-Bilson‘s blog while reading about the second point above (caching pages with URL params).
    It deals with the number of items in the ColdFusion cache when the cfcache tag is used to cache page fragments.

    If you have a cfcache tag in your code, your cache will contain one item.
    If you change the position of the cfcache tag (you move it one line below), your cache will contain two items.
    You can read the cache content using the getAllTemplateCacheIds() function.
    The example in the link above is pretty suggestive.

    Each page fragments gets its own entry in the cache since fragments can be independently expired or flushed from the cache. […] What’s happening is that ColdFusion is using the position of the code in your page as part of the ID for the cached item.

A beginner’s guide to start blogging

Written on 6 March 2011, 11:54pm

Tagged with: , , , , ,

So, you know you want to start a new blog, you bought your domain, set up the hosting and are ready to go. You have a lots of ideas about how your blog will look like, what kind of articles will contain, what friends will be in your blogroll. What’s next?
Here is a quick checklist which you will find useful when setting up your blog.

Image credit: Trey Ratcliff – Morning Fog in Jester

1. The content

  • The content is king. You probably know this already: the content is the most important part of your blog. No matter how cool it looks, how many likes you have on facebook – the content is the one that will determine the success or the failure of your blog.
  • Bring value. Quality content doesn’t mean rewriting the same idea with other words. If you found an interesting topic somewhere, don’t write a post to duplicate the content. You have twitter for sharing. On your blog you must express your own opinion: be creative, think about the same topic in other ways.
  • Know your audience. You need to know what is your target audience and tailor your style accordingly.
  • Always spell check your posts. Forgetting or ignoring this is simply unacceptable.