AnCH Framework 0.1
Another C++ Hack Framework
Loading...
Searching...
No Matches
anch::sql::SelectBuilder Class Reference

Dynamic SQL select request builder. More...

#include <selectBuilder.hpp>

Collaboration diagram for anch::sql::SelectBuilder:

Public Member Functions

virtual ~SelectBuilder ()
SelectBuilderdistinct ()
anch::sql::FieldsBuilder field (const std::string &column)
anch::sql::FieldsBuilder groupBy (const std::string &column)
anch::sql::FieldsBuilder orderBy (const std::string &column)
SelectBuilderhaving (anch::sql::ClausesBuilder &clauses)
SelectBuilderunionOnce (SelectBuilder &other)
SelectBuilderunionAll (SelectBuilder &other)
SelectBuilderoffset (int64_t offset)
SelectBuilderfetch (uint64_t limit)
SelectBuilderwindowByRowNumber (const std::string &alias, const std::string &rowColumn, const std::string &order, uint32_t min, uint32_t max)
SelectBuilderwindowByRank (const std::string &alias, const std::string &rowColumn, const std::string &order, uint32_t min, uint32_t max)
anch::sql::SQLQuery build ()

Friends

SelectBuilder anch::sql::select ()
std::ostream & operator<< (std::ostream &stream, const SelectBuilder &builder)

Detailed Description

Dynamic SQL select request builder.

Dynamic SQL select request builder

Author
Vincent Lachenal
Since
0.1

Constructor & Destructor Documentation

◆ ~SelectBuilder()

virtual anch::sql::SelectBuilder::~SelectBuilder ( )
virtual

SelectBuilder destructor

Member Function Documentation

◆ build()

anch::sql::SQLQuery anch::sql::SelectBuilder::build ( )

Build SQL query

Returns
the query and its prepared statement values

◆ distinct()

SelectBuilder & anch::sql::SelectBuilder::distinct ( )

Add DISTINCT command

Returns
this

◆ fetch()

SelectBuilder & anch::sql::SelectBuilder::fetch ( uint64_t limit)

Add FETCH FIRST n ROWS ONLY

Parameters
limitthe limit value
Returns
this

◆ field()

anch::sql::FieldsBuilder anch::sql::SelectBuilder::field ( const std::string & column)

Intialize a new fields builder

Returns
the fields builder

◆ groupBy()

anch::sql::FieldsBuilder anch::sql::SelectBuilder::groupBy ( const std::string & column)

Add SQL GROUP BY command

Parameters
columnthe first column to group by
Returns
a new FieldsBuilder to add other columns

◆ having()

SelectBuilder & anch::sql::SelectBuilder::having ( anch::sql::ClausesBuilder & clauses)

Add SQL HAVING command and its clauses if not empty

Parameters
clausesthe clauses
Returns
this
Here is the call graph for this function:

◆ offset()

SelectBuilder & anch::sql::SelectBuilder::offset ( int64_t offset)

Add OFFSET n ROWS

Parameters
offsetthe offset value
Returns
this
Here is the call graph for this function:

◆ orderBy()

anch::sql::FieldsBuilder anch::sql::SelectBuilder::orderBy ( const std::string & column)

Add SQL ORDER BY command

Parameters
columnthe first column to group by
Returns
a new FieldsBuilder to add other columns

◆ unionAll()

SelectBuilder & anch::sql::SelectBuilder::unionAll ( SelectBuilder & other)

Add UNION to other SQL request

Parameters
otherthe other SQL request
Returns
this

◆ unionOnce()

SelectBuilder & anch::sql::SelectBuilder::unionOnce ( SelectBuilder & other)

Add UNION to other SQL request

Parameters
otherthe other SQL request
Returns
this

◆ windowByRank()

SelectBuilder & anch::sql::SelectBuilder::windowByRank ( const std::string & alias,
const std::string & rowColumn,
const std::string & order,
uint32_t min,
uint32_t max )

Modify current query to add apply rank window function as define in SQL:2003 standard.

Parameters
aliasthe current query table alias
rowColumnthe row column alias
orderthe ORDER instruction
minthe minimum row number value
maxthe maximum row number value
Returns
this

◆ windowByRowNumber()

SelectBuilder & anch::sql::SelectBuilder::windowByRowNumber ( const std::string & alias,
const std::string & rowColumn,
const std::string & order,
uint32_t min,
uint32_t max )

Modify current query to add apply row_number window function as define in SQL:2003 standard.

Parameters
aliasthe current query table alias
rowColumnthe row column alias
orderthe ORDER instruction
minthe minimum row number value
maxthe maximum row number value
Returns
this

◆ operator<<

std::ostream & operator<< ( std::ostream & stream,
const SelectBuilder & builder )
friend

SelectBuilder stream insertion operator

Parameters
streamthe output stream
builderthe SelectBuilder
Returns
the output stream

The documentation for this class was generated from the following file: