qb — a Query Builder for the rest of us

By Eric Peterson

Elevator Pitch

qb is a Query Builder for CFML. If you’ve ever manually concatenated SQL strings, you understand the pain that qb solves. qb enables advanced query patterns, encourages object-oriented code, and bridges the idiosyncrasies between database grammars. Whether your project is big or small, qb can help.

Description

qb is a fluent query builder for CFML. Using qb, you can:

  • Quickly scaffold simple queries
  • Make complex, out-of-order queries possible
  • Abstract away differences between database engines

qb enables you to explore new ways of organizing your code by letting you pass around a query builder object that will compile down to the right SQL without you having to keep track of the order, whitespace, or other SQL gotchas!

Here’s an example of a complex qb query and it’s accompanying queryExecute code:

``` query = wirebox.getInstance( “QueryBuilder@qb” ); q = query.from( “posts” ) .orderBy( “published_at” ) .select( [ “post_id”, “author_id”, “title”, “body” ] ) .join( “authors”, “authors.id”, “=”, “posts.author_id” ) .whereLike( “authors.name”, “Ja%” ) .get();

// Becomes

q = queryExecute( “SELECT post_id, author_id, title, body FROM posts INNER JOIN authors ON authors.id = posts.author_id WHERE authors.name LIKE ? ORDER BY published_at”, [ { value = ‘Ja%’, cfsqltype = ‘CF_SQL_VARCHAR’, list = false, null = false } ] ); ```

qb enables new types of advanced queries like Query Filter objects cleaning up your code even further.

Whether you are writing simple or complex queries, qb is the tool for you. Come see why.

Notes

I am the creator and principal developer of qb. Your attendees will want to know about qb because it addresses pain points in an area where 99% of your attendees work every day — the database.