DataFaucet ORM

SQL Debugging

All SQL statement objects, irrespective of their other properties have a "debug" property which is false by default, allowing you to selectively enable the ColdFusion debugging output for specific queries as needed.

If debugging were enabled for all queries by default, you would be unable to use the name or location of the executed query to identify it because all queries are executed by the same function, so every query in the debugging output would look like this:

qry (Datasource=[DSN], Time=[xx]ms, Records=[x]) ↵ 
  in C:\apache\htdocs\datafaucet\system\agent\engine.cfc @ 15:10:45.045

So to resolve this problem, the faucet disables debugging by default and allows you to enable it for specific queries as needed.

<cfset qry = stmt.setValue("debug",true).execute() />

If you want to see all the queries executed within a particular segment of code (such as an included template) without knowing what code is executed within that code segment, you can enable debugging for all queries via the faucet's trace command (TRON):

<cfscript>   // get the faucet 
  faucet = request.DataFaucet 
  // get the datasource 
  ds = faucet.getDatasource 
  // enable debugging 
  // fetch a query - this is debugged"*","myTable"); 
  // disable debugging 
  // fetch another query - this is not debugged"*","myTable"); 

Most of the trime, TRON/TROFF isn't very useful with later versions of ColdFusion, since the executed SQL is shown if you display the query with CFDUMP however, like setting the debug property of an individual statement object, this requires you to know which query you want to debug in advance. The usefulness of TRON is really apparent when you have a page that's taking a long time to execute and you want to determine if perhaps it is executing too many queries in the page. You can then enable the trace to determine how many queries are executing and based on the debug output you can determine if a stored procedure or some other method might be a better alternative.