Wt  4.1.0
Public Member Functions | List of all members
Wt::Dbo::AbstractQuery Class Reference

An abstract dynamic database query. More...

#include <Wt/Dbo/Query.h>

Inheritance diagram for Wt::Dbo::AbstractQuery:
Inheritance graph
[legend]

Public Member Functions

template<typename T >
AbstractQuerybind (const T &value)
 Binds a value to the next positional marker. More...
 
void reset ()
 Resets bound values. More...
 
AbstractQueryjoin (const std::string &other)
 Adds a join. More...
 
AbstractQueryleftJoin (const std::string &other)
 Adds a left join. More...
 
AbstractQueryrightJoin (const std::string &other)
 Adds a right join. More...
 
AbstractQuerywhere (const std::string &condition)
 Adds a query condition. More...
 
AbstractQueryorderBy (const std::string &fieldName)
 Sets the result order. More...
 
AbstractQuerygroupBy (const std::string &fields)
 Sets the grouping field(s). More...
 
AbstractQueryhaving (const std::string &fields)
 Sets the grouping filter(s). More...
 
AbstractQueryoffset (int count)
 Sets a result offset. More...
 
int offset () const
 Returns an offset set for this query. More...
 
AbstractQuerylimit (int count)
 Sets a result limit. More...
 
int limit () const
 Returns a limit set for this query. More...
 

Detailed Description

An abstract dynamic database query.

See also
Query

Member Function Documentation

◆ bind()

template<typename T >
AbstractQuery & Wt::Dbo::AbstractQuery::bind ( const T &  value)

Binds a value to the next positional marker.

This binds the value to the next positional marker in the query condition.

◆ groupBy()

AbstractQuery & Wt::Dbo::AbstractQuery::groupBy ( const std::string &  fields)

Sets the grouping field(s).

This is a convenience method for creating a SQL query, and sets a group by field expression for the current query.

Groups results based on unique values of the indicated field(s), which is a comma separated list of fields. Only fields on which you group and aggregate functions can be selected by a query.

A field that refers to a database object that is selected by the query is expanded to all the corresponding fields of that database object (as in the select statement).

◆ having()

AbstractQuery & Wt::Dbo::AbstractQuery::having ( const std::string &  fields)

Sets the grouping filter(s).

It's like where(), but for aggregate fields.

For example you can't go:

select department.name, count(employees) from department where count(employees) > 5 group by count(employees);

Because you can't have aggregate fields in a where clause, but you can go:

select department.name, count(employees) from department group by count(employees) having count(employees) > 5;

This will of course return all the departments with more than 5 employees (and their employee count).

Note
You must have a group by clause, in order to have a 'having' clause

◆ join()

AbstractQuery & Wt::Dbo::AbstractQuery::join ( const std::string &  other)

Adds a join.

This is a convenience method for creating a SQL query, and concatenates a new join to the current query.

The join should be a valid SQL join expression, e.g. "customer c on o.customer_id = c.id"

Note
This method is not available when using a DirectBinding binding strategy.

◆ leftJoin()

AbstractQuery & Wt::Dbo::AbstractQuery::leftJoin ( const std::string &  other)

Adds a left join.

This is a convenience method for creating a SQL query, and concatenates a new left join to the current query.

The join should be a valid SQL join expression, e.g. "customer c on o.customer_id = c.id"

Note
This method is not available when using a DirectBinding binding strategy.

◆ limit() [1/2]

AbstractQuery & Wt::Dbo::AbstractQuery::limit ( int  count)

Sets a result limit.

Sets a result limit. This has the effect that the next resultList() call will return up to count results. Use -1 to indicate no limit.

This provides the (non standard) limit part of an SQL query.

See also
offset()

◆ limit() [2/2]

int Wt::Dbo::AbstractQuery::limit ( ) const

Returns a limit set for this query.

See also
limit(int)

◆ offset() [1/2]

AbstractQuery & Wt::Dbo::AbstractQuery::offset ( int  count)

Sets a result offset.

Sets a result offset. This has the effect that the next resultList() call will skip as many results as the offset indicates. Use -1 to indicate no offset.

This provides the (non standard) offset part of an SQL query.

See also
limit()

◆ offset() [2/2]

int Wt::Dbo::AbstractQuery::offset ( ) const

Returns an offset set for this query.

See also
offset(int)

◆ orderBy()

AbstractQuery & Wt::Dbo::AbstractQuery::orderBy ( const std::string &  fieldName)

Sets the result order.

This is a convenience method for creating a SQL query, and sets an order by field expression for the current query.

Orders the results based on the given field name (or multiple names, comma-separated).

◆ reset()

void Wt::Dbo::AbstractQuery::reset ( )

Resets bound values.

This undoes all previous calls to bind().

◆ rightJoin()

AbstractQuery & Wt::Dbo::AbstractQuery::rightJoin ( const std::string &  other)

Adds a right join.

This is a convenience method for creating a SQL query, and concatenates a new right join to the current query.

The join should be a valid SQL join expression, e.g. "customer c on o.customer_id = c.id"

Note
This method is not available when using a DirectBinding binding strategy.

◆ where()

AbstractQuery & Wt::Dbo::AbstractQuery::where ( const std::string &  condition)

Adds a query condition.

This is a convenience method for creating a SQL query, and concatenates a new where condition expression to the current query.

The condition must be a valid SQL condition expression.

Multiple conditions may be provided by successive calls to where(), which must each be fulfilled, and are concatenated together using 'and'.

As with any part of the SQL query, a condition may contain positional markers '?' to which values may be bound using bind().


Generated on Wed Jul 31 2019 for the C++ Web Toolkit (Wt) by doxygen 1.8.13