Dump sql query to screen

220 views
Skip to first unread message

Risto

unread,
Mar 22, 2011, 2:17:26 PM3/22/11
to ColdFusion on Wheels
Hi,

Any way to dump cfwheels sql query to screen without turning on cf
debugging?

Works locally, not on live server so don't want to turn on debugging.

Got one of these:

You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use
near ') )' at line 1

Thanks

Randy Johnson

unread,
Mar 22, 2011, 2:21:40 PM3/22/11
to cfwh...@googlegroups.com, Risto
a cftry catch around the code with a cfdump var=#cfatch# in the cfcatch would probably do the trick.

<cftry>

<cfset contact = model("property").findall(where="id=xxx")>

<cfcatch>
<cfdump var="#Cfcatch#">
</cfcatch>
</cftry>


--
You received this message because you are subscribed to the Google Groups "ColdFusion on Wheels" group.
To post to this group, send email to cfwh...@googlegroups.com.
To unsubscribe from this group, send email to cfwheels+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cfwheels?hl=en.




--
Randy Johnson / Web Programmer
InterCoastal Net Designs
PO Box 7633
6649 Beach Dr. SW
Ocean Isle Beach, NC 28469
P. 910-575-6095 / 866-249-6095
F. 910-575-1095

Andy Bellenie

unread,
Mar 22, 2011, 2:24:12 PM3/22/11
to cfwh...@googlegroups.com
One way is to put the content of the query into a cfsavecontent block,
then wrap the query in a cftry and dump the content if it errors.

Unfortunately you can't use cfqueryparam with this method, but it will
help you find the bug, and then you can put the params in afterwards.

Andy Bellenie

unread,
Mar 22, 2011, 2:24:33 PM3/22/11
to cfwh...@googlegroups.com
Or that :)

Risto

unread,
Mar 22, 2011, 3:36:20 PM3/22/11
to ColdFusion on Wheels
Dumping the cfcatch works, except in my case it didn't help because it
says sql "))"

I'll be sure to post if any other methods except turning on
cfdebugging works in my case.


Thanks


On Mar 22, 2:24 pm, Andy Bellenie <andybelle...@gmail.com> wrote:
> Or that :)
>
> On 22 March 2011 18:21, Randy Johnson <rjohn...@icoastalnet.com> wrote:
>
> > a cftry catch around the code with a cfdump var=#cfatch# in the cfcatch
> > would probably do the trick.
> > <cftry>
> > <cfset contact = model("property").findall(where="id=xxx")>
> > <cfcatch>
> > <cfdump var="#Cfcatch#">
> > </cfcatch>
> > </cftry>
>

Randy Johnson

unread,
Mar 23, 2011, 9:48:56 AM3/23/11
to cfwh...@googlegroups.com, Risto
I am kind of surprised to hear this, normally if the catch type is SQL then it will display the query it tried to run.

Did you figure out what the issue was?

Randy

Risto

unread,
Mar 23, 2011, 9:58:52 AM3/23/11
to ColdFusion on Wheels
My gut feeling is the mySQL table on server having the problem does
not have the same schema, field types, keys defined. It works locally.

It wasn't a project started from scratch and different people work on
it. I have a feeling that with many people working on it
something on the live db got modified.

I'll definitely post when I track it down.




On Mar 23, 9:48 am, Randy Johnson <rjohn...@icoastalnet.com> wrote:
> I am kind of surprised to hear this, normally if the catch type is SQL then
> it will display the query it tried to run.
>
> Did you figure out what the issue was?
>
> Randy
>

Risto

unread,
Mar 23, 2011, 10:29:29 AM3/23/11
to ColdFusion on Wheels
Hi,

It ended up being that the live db had the primary key set as just
unique key and not primary.
Made the change and it worked!
Reply all
Reply to author
Forward
0 new messages