CF Coding Practices
  • General Coding Practices
  • Debugging JSON-based CFC Methods
    • Valid JSON Formatting
    • Validating JSON
    • Final Hints
  • How We Invoke Modals
  • Submit Handlers
  • Useful SQL Snippets
  • jQuery/JS How-Tos And Hints
  • jQuery dataTables Tricks
  • CFSCRIPT Snippets and Hints
  • StatusPage Integration
  • Windows Server Setup
  • Common CF Formatting Commands
  • CF Snippets & Hints
  • Developing With The Mura Platform
    • ContentRenderer.CFC
    • Iterators
    • Iterating Remote Feeds
    • Components
    • Nested Content and Interactive Page Assembly
    • Modules and Display Objects
Powered by GitBook
On this page

Was this helpful?

  1. Debugging JSON-based CFC Methods

Final Hints

  • If you're outputing query records as part of your debug routine, it is sometimes easier to limit the query results to just a few records, particularly when encoding the output as JSON. You can limit any query objects results by using the "setMaxRows()" method and passing the desired number of rows (e.g. queryObj.setMaxRows(1))

  • If you need to know that exact SQL that was submitted as part of a successful query, you can use the getPrefix() function to output a structure (note that this is a complex object and should be outputed like the other complex objets referenced above using the savecontent method). For example, queryObj.execute().getPrefix() will return a structure with the SQL command, record count, SQL parameters (if any), etc. for the associated query object.

  • If you need to know that exact SQL that was submitted as part of an unsuccessful query, you can use error trapping via a try/catch setup. The catch portion should be written as "catch (any e) {}". You can then get the exact SQL command issued by output the e.sql string. Likewise, e.message and e.detail will have the specifics of the error that was caught by the catch condition.

PreviousValidating JSONNextHow We Invoke Modals

Last updated 6 years ago

Was this helpful?