Contact Doug!
Learn About Doug!
View Doug Boude's online resume
updated 11/18/2009

View Doug Boude's profile on LinkedIn
Link to me!

Follow Doug Boude on Twitter
Follow me!

Be Doug's friend on Facebook
Befriend me!
(I promise not to follow you home)
OO Lexicon
Chat with Doug!
Recent Entries
You may also be interested in...
Web Hosting

<< December, 2014 >>
Search Blog

Recent Comments
Re: My Top 20 Life Lessons for Boys and Young Men (by jeffrey scott berry at 9/16 2:42 PM)
Re: Equivalent of SQL "TOP X" in Oracle (by Mark Foster at 7/07 4:04 PM)
Re: SQL Forward Engineering with Visio 2003 Professional (by Thomas at 6/26 4:41 AM)
Re: One Shot Query to Recalculate Orderby Field - MySQL (by gary at 6/17 6:46 PM)
Re: DON'T GET SICK IN ARKANSAS! (by r. wood at 5/25 12:00 AM)
Re: SQL Forward Engineering with Visio 2003 Professional (by Andrew at 4/30 6:14 AM)
Re: Basic Ajax Select List Filter in PHP (by good at 2/04 5:26 AM)
Re: Family Law: The Weapon of Choice for Woman Scorned (by swalker at 2/03 2:15 AM)
Re: Approaches to Building Strings: The Imploding Array (by bantal silikon at 2/01 9:44 PM)
Re: Disappearing IE Popup Window During Save/Open Dialog (by AddisonDean at 1/15 9:59 AM)
Re: My Top 20 Life Lessons for Boys and Young Men (by Alex at 1/13 8:45 PM)
Re: Array Loop Modifications in CFSCRIPT (by Alex at 11/25 11:18 AM)
Re: Array Loop Modifications in CFSCRIPT (by Abram at 11/14 11:32 PM)
Re: Recursive Functions in ColdFusion (by Dwayne at 10/25 3:47 PM)
Re: Porting Coldfusion Code to Mura (by dh at 10/16 10:14 AM)
Re: Viewing Option Text (in IE7) that's Wider than the Select List (by Devil May Cry at 9/26 1:38 AM)
Re: Why I Hate ORMs (a solicited rant) (by guideX at 9/12 11:38 PM)
Re: Recursive Functions in ColdFusion (by KP at 8/08 7:13 PM)
Re: American Airlines, YOU SUCK! (by Alison at 7/23 4:48 PM)
Re: SQL Forward Engineering with Visio 2003 Professional (by Harshad at 7/11 9:17 AM)
Photo Albums
Funnies (5)
Family (3)

Powered by
BlogCFM v1.11

05 December 2013
One Shot Query to Recalculate Orderby Field - MySQL

In my app, a 'listing' can have one or more photos associated with it. These photo records live in their own table...listingImages. I allow the user to decide in what order the photos should be displayed, so I have a field in the table called 'imageOrder' that stores a number to sort by when outputting. When a user edits a listing and decides to delete one or more photos, I need to update the table's 'imageOrder' field for the remaining photos. Now, if I did NOT do this, the images would still be sorted in the correct order (I think), but I would much prefer to have an imageOrder value list that begins with 1. best to accomplish this. There are a hundred ways to do anything, and I probably considered at least three or four of them before settling on one that involved the execution of a single query. Here it is, in all its glory and for your (and my) future reference:


UPDATE listingimages i
inner join (
 SELECT  l.imageid,   
         @curRow := @curRow + 1 AS row_number
 FROM    listingimages l
 JOIN    (SELECT @curRow := 0) r
 WHERE   l.listingID = 5
 order by l.imageorder
) l on i.imageid = l.imageid
SET i.imageorder = l.row_number

Works like a champ! Note that in my subquery, I'm including an 'order by' that sorts the existing records by their current imageorder value. This is necessary so that the first image (whether it's current imageorder value was 3 or 300) ends up with a value of 1, the second record gets a value of 2, etc.

This particular solution is specific to MySQL, but I'm certain there are equivalent versions of this for any other flavor of DB as well.

Hope this helps someone!

Posted by dougboude at 5:08 PM | PRINT THIS POST! | Link | 1 comment

14 November 2013
Array Loop Modifications in CFSCRIPT

My latest CF 9 project is being done entirely in cfscript (well, except for my views and layouts), and so I'm learning a lot about how to write the script equivalent of many tags. I came across something I think is pretty cool, so thought I'd share it in case it helps someone else.

You know how we're always needing to iterate over lists, right? And in googling for the different approaches, the one I found most prevalently was a for loop using an incrementing counter over the array'd version of the list. Something like this:

var a = listToArray(myList);
var i = "";
for (i = 1; i LTE arrayLen(a); i = i + 1)

Pretty straightforward, but not very pretty. I much prefer a FOR IN loop, such as:

var a = listToArray(myList);
var i = "";
for (i IN a){

I like that approach much better...just seems cleaner and more beautiful to me. But then it occurred to me to try one of those things that anyone who's been using CF for any length of time can relate to, one of those things that cause you to initially think "hey, this way would be cool", immediately followed by "but I bet CF can't do that though". More often than not, I have found that the latter statement was true. But in this case, it actually worked.

I decided I wanted to do the FOR IN loop, but wanted to create my array inline rather than beforehand. Like so:

var i = "";
for (i IN #ListToArray(myList)#){

And what do you know, it actually worked. So of course, being a lover of concise code, I decided to take it one step further and see if I could declare the private variable 'i' inline as well, like so:

for (var i IN #ListToArray(myList)#){

That worked too! And just as an experiment, I tried this iteration which also worked:

for (var i IN ['first list item','second list item','third list item']){

Anyway, just thought I'd toss that out there.


Posted by dougboude at 5:02 PM | PRINT THIS POST! | Link | 2 comments
30 October 2013
Review: Man in the Moon

I find it challenging to review this show...I can't call it a movie, or a was something delightfully in a genre all its own. Although attempting to review something that I found to be so universally relevant and profound on many levels is difficult, I feel compelled to attempt to do so anyway. One wants to ensure that justice is served, and very often words cannot fully represent the thoughts, soul-searching, and visceral reactions that some events induce in a thinking person; especially the event entitled 'Man in the Moon', of which I had the privilege of partaking last night.

Man in the Moon is in one sense yet another accelerated presentation of the history of Earth and mankind; a clear and concise highlighting of the events that compose the history of the world. But this version of history is provided from a distinctly unique perspective. It is a recounting by one who had the privilege of being witness to this story from the very beginning, and who clearly did and does love his 'Blue' and its 'beasts' with all of his heart, soul, and being. He is the Lesser Light, but not really a light at all, as he humbly acknowledges; he is The Moon.

He was there when the earth was without form, and void, and over the eons of watching her take shape and come alive, he fell deeply in love with the creation he came to call Blue. One day, in a moment, there appeared an upright walking creature he called 'beast'. He did not know what to make of it at first, and with a great curiosity he watched it night after night, until eventually by the great potential for beauty, ingenuity, and good that he saw in the beast, he grew to love them, too. It was for this love's sake that his heart was broken time and time again as he watched this beast, this creature in whom the Creator had lovingly placed a bit of His own light, turn on one another and forget the Light from which they sprang. The Moon wanted to intervene, to warn, to correct, but could only watch from his post in the night sky as mankind eventually provoked such wrath from the Creator that he had succeeded in destroying himself by water. Ah, but to The Moon's great joy he saw that a remnant of the beast had been preserved! A small bark of Gopher wood bobbed freely on the waves, and in it a cargo more precious than any ship ever carried. After the waters receded, the beasts replenished the earth and filled it with their kind once again. And once again, to The Moon's horror, he watched as his beloveds turned on one another over time and used their evil imaginations to invent yet more and horrific ways of destroying themselves. It did not, however, go unnoticed by The Moon that always there was a remnant, a small portion of the beasts, in whom the Light of their Creator shone brightly and plainly. That always, despite however great the plague of wickedness that the beasts proliferated among themselves, the beauty of the beast managed to persevere and would not be quenched. This seemingly indestructible light of the beast gave the Man in the Moon unwaivering hope for mankind, that their future might be secure in that there were always some who were faithful to look to the heavens for their inspiration and guidance. The beast looked at the Man in the Moon, and the Man in the Moon looked lovingly upon his beloved beasts.

The Man in the Moon continued his story until he came to the present, where he could only leave his audience with an ending of darkness and obscurity. You see, he did not know the ending to the story, for as he related to his beloved beasts that were listening attentively, the ending had been given completely into their hands to determine. If they would but recognize, remember, and embrace the greatness of the Light that had been placed within them by He who had created them, then there was hope that the ending to this story for themselves and for their posterity would be a happy one. But, if they continued to choose blindness, to live as those creatures they themselves referred to as beasts; if they continued to perpetrate hatred, evil, and despising of their fellow man, the ending was certain, and their doom assured.

The Man in the Moon appeared and spoke to us for one evening in an attempt to help us see ourselves as we are and as we are capable of being, both individually and more importantly, as a whole. This humble recipient of the Man in the Moon's story was moved to tears on more than one occasion. Not so much by what was said as by how the words lighted upon my mind and heart. As I allowed myself to be reproved, to be shown, to look at that which one rarely looks upon without a profound reason to do so, I saw the potential within myself and all of us of which the Man in the Moon spoke.

I cannot close this review without bringing your attention back to the fact that this event was unlike any other I have ever seen. It was a unique combination of advanced projection and mapping technologies, state of the art robotics and makeup artistry, pyrotechnics, and old fashioned tried and true miniatures and stop motion animation. To top it all off, it was presented live on stage in an outdoor venue in Utah. Production of Man in the Moon took a year and a half from idea to final presentation. It was, in my opinion, a work of genius. The technical aspect of it was amazing on its own merit; but the absolute passion and love in both the story, the way in which it was presented, and in the golden thread of the underlying message that was so skillfully woven throughout from beginning to end make this a show of which every thinking person should find a way to partake.

If you're not already a subscriber to The Blaze network, I highly recommend that you check it out. It is quickly becoming THE premier news source for thinking people everywhere, and is growing in leaps and bounds on a daily basis as it expands its current programming and begins to diversify into the arena of movie production as well.

Posted by dougboude at 10:24 AM | PRINT THIS POST! | Link | 0 comments