Installation is easy through CommandBox and ForgeBox. Simply type box install qb
to get started.
To start a new query, instantiate a new Builder: wirebox.getInstance('QueryBuilder@qb')
.
By default, qb uses a generic Grammar. You can specify your specific grammar in ColdBox by setting the defaultGrammar
in your moduleSettings
.
The grammars provided by qb are:
MySQLGrammar
OracleGrammar
PostgresGrammar
SqlServerGrammar
If you are not using WireBox, just make sure to wire up the Builder
object with the correct grammar:
Note: These instructions assume a basic knowledge of FW/1, a working FW/1 application structure with qb installed in the
/subsystems
directory (manually or via CommandBox), and a database configured to run with your application.
Once the application structure is setup, now we need to wire up qb to a bean factory using DI/1.
First we will add a mapping in Application.cfc
.
Next we need to tell DI/1 where qb's components are and how to reference them for later use in the application. We can do so by defining the configuration settings in the variables.framework.subsystems
struct in Application.cfc
. The example below makes use of a load listener to declare each component instance and pass in any constructor arguments.
Now that everything is configured, you can launch your application with CommandBox by entering start
in the terminal or use whatever method you're accustomed to.
To access qb from your application's code, you can call on it by using getBeanFactory()
.