Constructs a new QueryBuilder with the Connection, so we can directly run queries with it.
Alias and to where, to allow stuff like User.where( ... ).and( ... )
Sets the builder's FROM value to the given string.
Same as above, but instead of accepting a string parameter, it instead accepts a type as a template parameter, then sets the value to that type's relation name. Preferred over the above version.
Sets the LIMIT in the query. Only for SELECT queries, obviously.
OFFSET for queries
Remembers the given key value pair, replacing the placeholders in the query before running it.
Sets the ORDER part of the query. Accepts a column name and an Order value.
Sets the builder's type to SELECT, a variadic array of column names to select
Same as above, except it accepts a variadic array of Column type. Mostly used internally.
Selects all the given relation's properties
Adds new filter(s). Param placeholders are used, with the same names as the AA keys. Calling this multiple times will AND the filters.
Adds a new custom filter.
Once called, all additional parameters will be placed into their own group, OR placed between each group of ANDs
1 auto qb = QueryBuilder() 2 .select("id") 3 .from!User 4 .where("posts > {posts}") // placeholders can be used 5 .order("posts", Order.desc) 6 .limit(5); 7 8 // Placeholders will be replaced ONLY if they are specified. 9 // No need to escape anything, as it sent with execParams 10 qb["posts"] = 50;
Provides a nice way of writing queries in D, as well as some handy shortcuts to working with D structures in the DB.
Most method names are synonimous with the same keyword in SQL, but their order does not matter.
All of the methods can be chained.