Run SQL Commands through DataMgr
You can also have DataMgr execute SQL commands for you. Generally you will be better off using cfquery for this purpose, but there are a few scenarios where DataMgr may provide some benefits:
- If the datasource may or may not have a username/password and you aren't sure when you write the code (as DataMgr can execute code with or without one and this would allow you to make that change in only one place).
- If you need to effectively create cfqueryparam tags on the fly outside of your SQL execution.
DataMgr has two methods for executing SQL (both of which are used internally but are public methods:
- runSQL(): This method takes a string of SQL and executes it against the database.
- runSQLArray(): This method takes and array that can hold strings, structure, and other arrays:
- Strings are passed directly into the query as SQL.
- Structures are treated as cfqueryparam tags and should have keys that match the attributes to be used.
- Arrays are evaluated for nested strings and structures as above.