Posted in ColdFusion | Posted on 11-22-2005 | 1,802 views
So, a few days ago I blogged about an issue with BlogCFC and MySQL/Access. I was able to reproduce it, but for the life of me, I couldn't figure out why the bug occured. I was able to fix it though, so I've updated the zip. Changes include:
- Fix for MySQL/Access. More on the issue below.
- Updated the TrackBack spam list. I highly encourage you to copy this setting even if you don't need the MySQL/Access fix. If all BlogCFC users have a strong TB spam list, it may encourage TB spammers to ignore the platform.
As always, you can download BlogCFC from the project page.
So - more on the bug. The bug was very odd. Basically org.hastings.utils.cfc would throw an error on this line: (I've added a few spaces in it to make it break nicely.)
The error stated the value of utcDate wasn't a valid date. Now - this is what I don't get. This CFC hasn't been touched in ages, probably over a year. The date values in the database hasn't changed since BlogCFC was released. Yet there it was - throwing errors. Now - I can say that my dev platform has changed. I used to run the "Simple" CF, ie, install, hook up to Apache, that's it. I've recently switched to CF installed in JRun. So maybe that was the key - but the question is - why hasn't anyone else complained?
Oh - and it gets better. The error was only thrown when you got categories. Let me make this a bit simpler and just paste in the email I sent when I originally asked for help. It may clear things up a bit. What follows is straight from an email, so forgive the fact that it may not match this entry well.
Now here is something that is baffling. BlogCFC has one uber-function to get blog entries. Depending on various filters, I modify the query a bit. For some reason, whenever I tell BlogCFC to get data and filter by a category, I get an error when I try to date format the data. (I'm not using CF's built in dateFormat though.)
I dumped the result of a simple, getEntries, versus a getEntries based on category. In both cases, while the entries were a bit different, the data was, essentially, the same.
On a whim I decided to dump the metadata on the query. For a normal getEntries, the posted column was datetime. For the getEntries/category filter, the value of the column was varchar!
Well - there ya go. Thing is - I can't understand why the query would change the posted column. Here is a sample of the query when doing a normal getEntries:
2tblblogentries.alias,
3date_add(posted, interval -1 hour) as posted,
4tblblogentries.username, tblblogentries.allowcomments,
5tblblogentries.enclosure, tblblogentries.filesize, tblblogentries.mimetype
6, tblblogentries.body, tblblogentries.morebody
7from tblblogentries
8
9
10where 1=1
11and blog = ?
12order by tblblogentries.posted desc
13limit 4
Now here is the query with a category filter:
2tblblogentries.alias,
3date_add(posted, interval -1 hour) as posted,
4tblblogentries.username, tblblogentries.allowcomments,
5tblblogentries.enclosure, tblblogentries.filesize, tblblogentries.mimetype
6, tblblogentries.body, tblblogentries.morebody
7
8from tblblogentries
9,tblblogentriescategories
10
11where 1=1
12and blog = ?
13and tblblogentriescategories.entryidfk = tblblogentries.id
14and tblblogentriescategories.categoryidfk = ?
15
16order by tblblogentries.posted desc
17limit 4
So - anyone have a bright idea?


Should the line be this:
date_add(tblblogentries.posted, interval -1 hour) as posted,
I wouldn't expect that to cause the problem, unless you added a "posted" column to tblblogentriescategories.
The line:
date_add(posted, interval -1 hour) as posted,
Could be:
date_add(tblblogentries.posted, interval -1 hour) as posted,
The column "posted" inside the date_add function is not qualified with the table name (every other column reference in the query is).
Of course, I would not expect this to cause the bug you're seeing.
I wonder if MySQL has a problem with aliases that are identical to table names?
Re-reading your original post, I'm unsure if you were still asking for help or if the bug was fixed.
I was wondering if had something to do with my regional settings being set to UK but haven't had time to look through it yet.
[Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'datepart('d', dateAdd(''h'', 1, tblblogentries.posted))'.
I have no idea what it means (although I am suspcious about a double quote appearing around the H for dateadd). Anyway, if this helps this bug diagnostics, great -- otherwise if anyone can tell me what I'm doing wrong I'd love to demo this thing. FYI, I'm running it as localhost (or 127.0.0.1:8500).
Dave
<cfelseif instance.blogDBType is "MSACCESS">
<cfset posted = "dateAdd('h', #instance.offset#, tblblogentries.posted)">
I definetely have MSACCESS set as the DBtype, but here is my evolved INI in the meantime (partially listed - sorry if this doesn't format well):
dsn=cfblog
owneremail=dpinero@fmhi.usf.edu
blogURL=http://127.0.0.1:8500/blog/client/index.cfm
unsubscribeURL=http://127.0.0.1:8500/blog/client/unsubscribe.cfm
blogTitle=BlogDev
blogDescription=The Dev Blog
blogItemURLPrefix=mode=entry&entry=
blogDBType=MSACCESS
locale=en_US
users=admin
commentsFrom=
mailserver=
mailusername=
mailpassword=
pingurls=
offset=1
allowtrackbacks=1
[Add Comment] [Subscribe to Comments]