QxOrm  1.5.0
C++ Object Relational Mapping library

qx::QxSqlQuery : define a user SQL query added to default SQL query builded by QxOrm library, and used by qx::dao::xxx functions to filter elements fetched from database More...

#include <QxSqlQuery.h>

List of all members.

Classes

struct  QxSqlResult

Public Types

typedef std::function< void(QString &)> type_fct_on_before_sql_prepare

Public Member Functions

 QxSqlQuery ()
 QxSqlQuery (const char *query, const QVariantList &values=QVariantList())
 QxSqlQuery (const QString &query, const QVariantList &values=QVariantList())
 QxSqlQuery (const QStringList &query)
 QxSqlQuery (const QString &type, const QString &query)
 QxSqlQuery (const QString &type, const QStringList &query)
virtual ~QxSqlQuery ()
QString query ()
QString queryAt (int idx) const
void queryAt (int idx, const QString &query)
QVariant response () const
QString type () const
bool isEmpty () const
bool isDistinct () const
void clear ()
void resolve (QSqlQuery &query, qx::QxCollection< QString, QVariantList > *pLstExecBatch=NULL) const
void resolveOutput (QSqlQuery &query, bool bFetchSqlResult)
void postProcess (QString &sql) const
void setResponse (const QVariant &v)
void setType (const QString &s)
QString getJoinQuery (const QString &relationKey, const QString &relationAlias)
QString getJoinQueryHash ()
QxSqlQueryquery (const QString &sQuery)
QxSqlQuerybind (const QVariant &vValue, QSql::ParamType paramType=QSql::In)
QxSqlQuerybind (const QString &sKey, const QVariant &vValue, QSql::ParamType paramType=QSql::In)
QVariant boundValue (const QString &sKey) const
QVariant boundValue (int iPosition) const
long getSqlResultRowCount () const
long getSqlResultColumnCount () const
QVariant getSqlResultAt (long row, long column) const
QVariant getSqlResultAt (long row, const QString &column, bool caseSensitive=false) const
QVector< QVariant > getSqlResultAt (long row) const
QVector< QString > getSqlResultAllColumns () const
void dumpSqlResult ()
QxSqlQuerysetFctOnBeforeSqlPrepare (type_fct_on_before_sql_prepare fct)
void onBeforeSqlPrepare (QString &sql)
virtual QxSqlQuerydistinct ()
virtual QxSqlQuerywhere (const QString &column)
virtual QxSqlQuerywhere_OpenParenthesis (const QString &column)
virtual QxSqlQueryand_ (const QString &column)
virtual QxSqlQueryand_OpenParenthesis (const QString &column)
virtual QxSqlQueryor_ (const QString &column)
virtual QxSqlQueryor_OpenParenthesis (const QString &column)
virtual QxSqlQueryopenParenthesis ()
virtual QxSqlQuerycloseParenthesis ()
virtual QxSqlQueryorderAsc (const QStringList &columns)
virtual QxSqlQueryorderAsc (const QString &col1)
virtual QxSqlQueryorderAsc (const QString &col1, const QString &col2)
virtual QxSqlQueryorderAsc (const QString &col1, const QString &col2, const QString &col3)
virtual QxSqlQueryorderAsc (const QString &col1, const QString &col2, const QString &col3, const QString &col4)
virtual QxSqlQueryorderAsc (const QString &col1, const QString &col2, const QString &col3, const QString &col4, const QString &col5)
virtual QxSqlQueryorderAsc (const QString &col1, const QString &col2, const QString &col3, const QString &col4, const QString &col5, const QString &col6)
virtual QxSqlQueryorderAsc (const QString &col1, const QString &col2, const QString &col3, const QString &col4, const QString &col5, const QString &col6, const QString &col7)
virtual QxSqlQueryorderAsc (const QString &col1, const QString &col2, const QString &col3, const QString &col4, const QString &col5, const QString &col6, const QString &col7, const QString &col8)
virtual QxSqlQueryorderAsc (const QString &col1, const QString &col2, const QString &col3, const QString &col4, const QString &col5, const QString &col6, const QString &col7, const QString &col8, const QString &col9)
virtual QxSqlQueryorderDesc (const QStringList &columns)
virtual QxSqlQueryorderDesc (const QString &col1)
virtual QxSqlQueryorderDesc (const QString &col1, const QString &col2)
virtual QxSqlQueryorderDesc (const QString &col1, const QString &col2, const QString &col3)
virtual QxSqlQueryorderDesc (const QString &col1, const QString &col2, const QString &col3, const QString &col4)
virtual QxSqlQueryorderDesc (const QString &col1, const QString &col2, const QString &col3, const QString &col4, const QString &col5)
virtual QxSqlQueryorderDesc (const QString &col1, const QString &col2, const QString &col3, const QString &col4, const QString &col5, const QString &col6)
virtual QxSqlQueryorderDesc (const QString &col1, const QString &col2, const QString &col3, const QString &col4, const QString &col5, const QString &col6, const QString &col7)
virtual QxSqlQueryorderDesc (const QString &col1, const QString &col2, const QString &col3, const QString &col4, const QString &col5, const QString &col6, const QString &col7, const QString &col8)
virtual QxSqlQueryorderDesc (const QString &col1, const QString &col2, const QString &col3, const QString &col4, const QString &col5, const QString &col6, const QString &col7, const QString &col8, const QString &col9)
virtual QxSqlQuerygroupBy (const QStringList &columns)
virtual QxSqlQuerygroupBy (const QString &col1)
virtual QxSqlQuerygroupBy (const QString &col1, const QString &col2)
virtual QxSqlQuerygroupBy (const QString &col1, const QString &col2, const QString &col3)
virtual QxSqlQuerygroupBy (const QString &col1, const QString &col2, const QString &col3, const QString &col4)
virtual QxSqlQuerygroupBy (const QString &col1, const QString &col2, const QString &col3, const QString &col4, const QString &col5)
virtual QxSqlQuerygroupBy (const QString &col1, const QString &col2, const QString &col3, const QString &col4, const QString &col5, const QString &col6)
virtual QxSqlQuerygroupBy (const QString &col1, const QString &col2, const QString &col3, const QString &col4, const QString &col5, const QString &col6, const QString &col7)
virtual QxSqlQuerygroupBy (const QString &col1, const QString &col2, const QString &col3, const QString &col4, const QString &col5, const QString &col6, const QString &col7, const QString &col8)
virtual QxSqlQuerygroupBy (const QString &col1, const QString &col2, const QString &col3, const QString &col4, const QString &col5, const QString &col6, const QString &col7, const QString &col8, const QString &col9)
virtual QxSqlQuerylimit (int rowsCount, int startRow=0, bool withTies=false)
virtual QxSqlQuerylike (const QString &val)
virtual QxSqlQuerynotLike (const QString &val)
virtual QxSqlQuerystartsWith (const QString &val)
virtual QxSqlQueryendsWith (const QString &val)
virtual QxSqlQuerycontainsString (const QString &val)
virtual QxSqlQueryisEqualTo (const QVariant &val)
virtual QxSqlQueryisNotEqualTo (const QVariant &val)
virtual QxSqlQueryisGreaterThan (const QVariant &val)
virtual QxSqlQueryisGreaterThanOrEqualTo (const QVariant &val)
virtual QxSqlQueryisLessThan (const QVariant &val)
virtual QxSqlQueryisLessThanOrEqualTo (const QVariant &val)
virtual QxSqlQuerycustomOperator (const QString &sCustomOperator, const QVariant &val)
virtual QxSqlQueryin (const QVariantList &values)
virtual QxSqlQueryin (const QVariant &val1)
virtual QxSqlQueryin (const QVariant &val1, const QVariant &val2)
virtual QxSqlQueryin (const QVariant &val1, const QVariant &val2, const QVariant &val3)
virtual QxSqlQueryin (const QVariant &val1, const QVariant &val2, const QVariant &val3, const QVariant &val4)
virtual QxSqlQueryin (const QVariant &val1, const QVariant &val2, const QVariant &val3, const QVariant &val4, const QVariant &val5)
virtual QxSqlQueryin (const QVariant &val1, const QVariant &val2, const QVariant &val3, const QVariant &val4, const QVariant &val5, const QVariant &val6)
virtual QxSqlQueryin (const QVariant &val1, const QVariant &val2, const QVariant &val3, const QVariant &val4, const QVariant &val5, const QVariant &val6, const QVariant &val7)
virtual QxSqlQueryin (const QVariant &val1, const QVariant &val2, const QVariant &val3, const QVariant &val4, const QVariant &val5, const QVariant &val6, const QVariant &val7, const QVariant &val8)
virtual QxSqlQueryin (const QVariant &val1, const QVariant &val2, const QVariant &val3, const QVariant &val4, const QVariant &val5, const QVariant &val6, const QVariant &val7, const QVariant &val8, const QVariant &val9)
virtual QxSqlQuerynotIn (const QVariantList &values)
virtual QxSqlQuerynotIn (const QVariant &val1)
virtual QxSqlQuerynotIn (const QVariant &val1, const QVariant &val2)
virtual QxSqlQuerynotIn (const QVariant &val1, const QVariant &val2, const QVariant &val3)
virtual QxSqlQuerynotIn (const QVariant &val1, const QVariant &val2, const QVariant &val3, const QVariant &val4)
virtual QxSqlQuerynotIn (const QVariant &val1, const QVariant &val2, const QVariant &val3, const QVariant &val4, const QVariant &val5)
virtual QxSqlQuerynotIn (const QVariant &val1, const QVariant &val2, const QVariant &val3, const QVariant &val4, const QVariant &val5, const QVariant &val6)
virtual QxSqlQuerynotIn (const QVariant &val1, const QVariant &val2, const QVariant &val3, const QVariant &val4, const QVariant &val5, const QVariant &val6, const QVariant &val7)
virtual QxSqlQuerynotIn (const QVariant &val1, const QVariant &val2, const QVariant &val3, const QVariant &val4, const QVariant &val5, const QVariant &val6, const QVariant &val7, const QVariant &val8)
virtual QxSqlQuerynotIn (const QVariant &val1, const QVariant &val2, const QVariant &val3, const QVariant &val4, const QVariant &val5, const QVariant &val6, const QVariant &val7, const QVariant &val8, const QVariant &val9)
virtual QxSqlQueryin_Select (const QxSqlQuery &query)
virtual QxSqlQuerynotIn_Select (const QxSqlQuery &query)
virtual QxSqlQueryisEqualTo_Select (const QxSqlQuery &query)
virtual QxSqlQueryisNotEqualTo_Select (const QxSqlQuery &query)
virtual QxSqlQueryisNull ()
virtual QxSqlQueryisNotNull ()
virtual QxSqlQueryisBetween (const QVariant &val1, const QVariant &val2)
virtual QxSqlQueryisNotBetween (const QVariant &val1, const QVariant &val2)
virtual QxSqlQueryfreeText (const QString &text, const QVariantList &values=QVariantList())
virtual QxSqlQueryaddJoinQuery (const QString &relationKeyOrAlias, const QxSqlQuery &joinQuery)

Static Public Member Functions

static void dumpBoundValues (const QSqlQuery &query)

Protected Types

typedef std::tuple< QVariant,
QSql::ParamType > 
type_bind_value

Protected Attributes

QStringList m_sQuery
 Query SQL with place-holder.
QxCollection< QString,
type_bind_value
m_lstValue
 Bind value in this array.
qx::dao::detail::IxSqlElement_ptr m_pSqlElementTemp
 Temporary SQL element.
QList
< qx::dao::detail::IxSqlElement_ptr
m_lstSqlElement
 List of all SQL elements to build SQL query.
int m_iSqlElementIndex
 Current index of SQL element.
int m_iParenthesisCount
 Current parenthesis count.
bool m_bDistinct
 Replace SELECT by SELECT DISTINCT in SQL query.
std::shared_ptr< QxSqlResultm_pSqlResult
 All results returning by SQL query or stored procedure (after calling qx::dao::call_query function)
QVariant m_vResponse
 Can be used to store some responses (from MongoDB database for example in JSON format)
QString m_sType
 Query type (for example : 'aggregate' or 'cursor' for MongoDB database)
QHash< QString,
std::shared_ptr< QxSqlQuery > > 
m_lstJoinQueryUser
 List of SQL queries defined by user to add inside relationships joins (LEFT OUTER JOIN, INNER JOIN), for example : INNER JOIN my_table2 m2 ON (m1.id = m2.parent_id AND (XXX))
QList< std::shared_ptr
< QxSqlQuery > > 
m_lstJoinQueryToResolve
 List of SQL queries to resolve (in the right order) to add inside relationships joins (LEFT OUTER JOIN, INNER JOIN), for example : INNER JOIN my_table2 m2 ON (m1.id = m2.parent_id AND (XXX))
type_fct_on_before_sql_prepare m_fctOnBeforeSqlPrepare
 Custom callback function to modify SQL query before preparing in database.

Private Member Functions

void verifyQuery () const QX_USED
void fetchSqlResult (QSqlQuery &query)
QxSqlQueryaddSqlExpression (const QString &column, qx::dao::detail::QxSqlExpression::type type)
QxSqlQueryaddSqlCompare (const QVariant &val, qx::dao::detail::QxSqlCompare::type type, const QString &sCustomOperator=QString())
QxSqlQueryaddSqlSort (const QStringList &columns, qx::dao::detail::QxSqlSort::type type)
QxSqlQueryaddSqlIn (const QVariantList &values, qx::dao::detail::QxSqlIn::type type)
QxSqlQueryaddSqlIsNull (qx::dao::detail::QxSqlIsNull::type type)
QxSqlQueryaddSqlIsBetween (const QVariant &val1, const QVariant &val2, qx::dao::detail::QxSqlIsBetween::type type)
QxSqlQueryaddFreeText (const QString &text, const QVariantList &values)
QxSqlQueryaddEmbedQuery (const QxSqlQuery &query, qx::dao::detail::QxSqlEmbedQuery::type type, bool requirePreviousElement)

Friends

struct qx::cvt::detail::QxConvert_ToJson< qx::QxSqlQuery >
struct qx::cvt::detail::QxConvert_FromJson< qx::QxSqlQuery >
template<class Archive >
void boost::serialization::qx_save (Archive &ar, const qx::QxSqlQuery &t, const unsigned int file_version)
template<class Archive >
void boost::serialization::qx_load (Archive &ar, qx::QxSqlQuery &t, const unsigned int file_version)
QX_DLL_EXPORT QDataStream & operator<< (QDataStream &stream, const qx::QxSqlQuery &t)
QX_DLL_EXPORT QDataStream & operator>> (QDataStream &stream, qx::QxSqlQuery &t)
QX_DLL_EXPORT QJsonValue qx::cvt::detail::QxConvert_ToJson_Helper (const qx::QxSqlQuery &t, const QString &format)
QX_DLL_EXPORT qx_bool qx::cvt::detail::QxConvert_FromJson_Helper (const QJsonValue &j, qx::QxSqlQuery &t, const QString &format)

Detailed Description

qx::QxSqlQuery : define a user SQL query added to default SQL query builded by QxOrm library, and used by qx::dao::xxx functions to filter elements fetched from database

The class qx::QxSqlQuery (or its typedef qx_query) is used to communicate with database (to filter, to sort, etc.) in two different ways :

  • writing manually SQL query ;
  • using C++ methods with a syntax similar to SQL (same concept than the great library SubSonic for .Net).

With the first method (writing manually SQL query), you can use some optimizations specific for each database. The second method (using C++ code to build SQL query) binds automatically SQL parameters without using qx::QxSqlQuery::bind() function.

Here is an example with qx::QxSqlQuery class writing manually a SQL query :

// Build a SQL query to fetch only 'author' of type 'female'
qx::QxSqlQuery query("WHERE author.sex = :sex");
query.bind(":sex", author::female);

QList<author> list_of_female;
QSqlError daoError = qx::dao::fetch_by_query(query, list_of_female);

// Here we can work with the collection provided by database
for (long l = 0; l < list_of_female.count(); l++) { ; }

QxOrm library provides 3 styles to write SQL parameters. This style can be modified for a project using the following method qx::QxSqlDatabase::getSingleton()->setSqlPlaceHolderStyle() :

  • ph_style_2_point_name : "WHERE author.sex = :sex" (default style) ;
  • ph_style_at_name : "WHERE author.sex = @sex" ;
  • ph_style_question_mark : "WHERE author.sex = ?".

Here is the same example using C++ code of the class qx::QxSqlQuery (or its typedef qx_query) to build query automatically :

// Build a SQL query to fetch only 'author' of type 'female'
qx_query query;
query.where("author.sex").isEqualTo(author::female);

QList<author> list_of_female;
QSqlError daoError = qx::dao::fetch_by_query(query, list_of_female);

// Here we can work with the collection provided by database
for (long l = 0; l < list_of_female.count(); l++) { ; }

With C++ methods of qx::QxSqlQuery class, you don't have to bind any SQL parameter, and the syntax is similar to real SQL. All SQL parameters will be provided to database automatically with the following style : qx::QxSqlDatabase::getSingleton()->getSqlPlaceHolderStyle().

Here is an example with many methods of qx::QxSqlQuery class (or its typedef qx_query) :

qx_query query;
query.where("sex").isEqualTo(author::female)
     .and_("age").isGreaterThan(38)
     .or_("last_name").isNotEqualTo("Dupont")
     .or_("first_name").like("Alfred")
     .and_OpenParenthesis("id").isLessThanOrEqualTo(999)
     .and_("birth_date").isBetween(date1, date2)
     .closeParenthesis()
     .or_("id").in(50, 999, 11, 23, 78945)
     .and_("is_deleted").isNotNull()
     .orderAsc("last_name", "first_name", "sex")
     .limit(50, 150);

This code will produce following SQL for MySQL, PostgreSQL and SQLite databases (for Oracle and SQLServer, there is a specific process for limit() method) :

WHERE sex = :sex_1_0 
AND age > :age_3_0 
OR last_name <> :last_name_5_0 
OR first_name LIKE :first_name_7_0 
AND ( id <= :id_10_0 AND birth_date BETWEEN :birth_date_12_0_1 AND :birth_date_12_0_2 ) 
OR id IN (:id_15_0_0, :id_15_0_1, :id_15_0_2, :id_15_0_3, :id_15_0_4) 
AND is_deleted IS NOT NULL 
ORDER BY last_name ASC, first_name ASC, sex ASC 
LIMIT :limit_rows_count_19_0 OFFSET :offset_start_row_19_0

Here is the list of all functions available to use qx::QxSqlQuery class (or its typedef qx_query) :

// with functions into namespace qx::dao
qx::dao::count<T>()
qx::dao::fetch_by_query<T>()
qx::dao::update_by_query<T>()
qx::dao::delete_by_query<T>()
qx::dao::destroy_by_query<T>()
qx::dao::fetch_by_query_with_relation<T>()
qx::dao::fetch_by_query_with_all_relation<T>()
qx::dao::update_by_query_with_relation<T>()
qx::dao::update_by_query_with_all_relation<T>()
qx::dao::update_optimized_by_query<T>()

// with qx::QxSession class
qx::QxSession::count<T>()
qx::QxSession::fetchByQuery<T>()
qx::QxSession::update<T>()
qx::QxSession::deleteByQuery<T>()
qx::QxSession::destroyByQuery<T>()

// with qx::QxRepository<T> class
qx::QxRepository<T>::count()
qx::QxRepository<T>::fetchByQuery()
qx::QxRepository<T>::update()
qx::QxRepository<T>::deleteByQuery()
qx::QxRepository<T>::destroyByQuery()

Note : those functions have 2 other optionals parameters :

  • const QStringList & columns : to indicate columns to fetch (by default, all columns are fetched) ;
  • const QStringList & relation : to indicate relations to fetch (one-to-one, one-to-many, many-to-one and many-to-many defined into void qx::register_class<T>() mapping function by class), by default there is no relation fetched.

Other note : it's possible to call a stored procedure using qx::QxSqlQuery class, for example :

qx_query query("CALL MyStoredProc(:param1, :param2)");
query.bind(":param1", "myValue1");
query.bind(":param2", 5024, QSql::InOut);
QSqlError daoError = qx::dao::call_query(query);
QVariant vNewValue = query.boundValue(":param2");
query.dumpSqlResult();

If the stored procedure returns a resultset, you can iterate over each rows and fields using the following methods (after calling qx::dao::call_query() function) :

Other note : to add your own SQL query methods (for example, some databases provide non-standard specifics SQL functions) :

Definition at line 244 of file QxSqlQuery.h.


Member Typedef Documentation

typedef std::tuple<QVariant, QSql::ParamType> qx::QxSqlQuery::type_bind_value [protected]

Definition at line 271 of file QxSqlQuery.h.

typedef std::function<void (QString &)> qx::QxSqlQuery::type_fct_on_before_sql_prepare

Definition at line 264 of file QxSqlQuery.h.


Constructor & Destructor Documentation

qx::QxSqlQuery::QxSqlQuery ( )
qx::QxSqlQuery::QxSqlQuery ( const char *  query,
const QVariantList &  values = QVariantList() 
)
qx::QxSqlQuery::QxSqlQuery ( const QString &  query,
const QVariantList &  values = QVariantList() 
)
qx::QxSqlQuery::QxSqlQuery ( const QStringList &  query)
qx::QxSqlQuery::QxSqlQuery ( const QString &  type,
const QString &  query 
)
qx::QxSqlQuery::QxSqlQuery ( const QString &  type,
const QStringList &  query 
)
virtual qx::QxSqlQuery::~QxSqlQuery ( ) [virtual]

Member Function Documentation

QxSqlQuery& qx::QxSqlQuery::addEmbedQuery ( const QxSqlQuery query,
qx::dao::detail::QxSqlEmbedQuery::type  type,
bool  requirePreviousElement 
) [private]
QxSqlQuery& qx::QxSqlQuery::addFreeText ( const QString &  text,
const QVariantList &  values 
) [private]
virtual QxSqlQuery& qx::QxSqlQuery::addJoinQuery ( const QString &  relationKeyOrAlias,
const QxSqlQuery joinQuery 
) [virtual]
QxSqlQuery& qx::QxSqlQuery::addSqlCompare ( const QVariant &  val,
qx::dao::detail::QxSqlCompare::type  type,
const QString &  sCustomOperator = QString() 
) [private]
QxSqlQuery& qx::QxSqlQuery::addSqlExpression ( const QString &  column,
qx::dao::detail::QxSqlExpression::type  type 
) [private]
QxSqlQuery& qx::QxSqlQuery::addSqlIn ( const QVariantList &  values,
qx::dao::detail::QxSqlIn::type  type 
) [private]
QxSqlQuery& qx::QxSqlQuery::addSqlIsBetween ( const QVariant &  val1,
const QVariant &  val2,
qx::dao::detail::QxSqlIsBetween::type  type 
) [private]
QxSqlQuery& qx::QxSqlQuery::addSqlIsNull ( qx::dao::detail::QxSqlIsNull::type  type) [private]
QxSqlQuery& qx::QxSqlQuery::addSqlSort ( const QStringList &  columns,
qx::dao::detail::QxSqlSort::type  type 
) [private]
virtual QxSqlQuery& qx::QxSqlQuery::and_ ( const QString &  column) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::and_OpenParenthesis ( const QString &  column) [virtual]
QxSqlQuery& qx::QxSqlQuery::bind ( const QVariant &  vValue,
QSql::ParamType  paramType = QSql::In 
)
QxSqlQuery& qx::QxSqlQuery::bind ( const QString &  sKey,
const QVariant &  vValue,
QSql::ParamType  paramType = QSql::In 
)
QVariant qx::QxSqlQuery::boundValue ( const QString &  sKey) const
QVariant qx::QxSqlQuery::boundValue ( int  iPosition) const
void qx::QxSqlQuery::clear ( )
virtual QxSqlQuery& qx::QxSqlQuery::closeParenthesis ( ) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::containsString ( const QString &  val) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::customOperator ( const QString &  sCustomOperator,
const QVariant &  val 
) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::distinct ( ) [virtual]
static void qx::QxSqlQuery::dumpBoundValues ( const QSqlQuery &  query) [static]
void qx::QxSqlQuery::dumpSqlResult ( )
virtual QxSqlQuery& qx::QxSqlQuery::endsWith ( const QString &  val) [virtual]
void qx::QxSqlQuery::fetchSqlResult ( QSqlQuery &  query) [private]
virtual QxSqlQuery& qx::QxSqlQuery::freeText ( const QString &  text,
const QVariantList &  values = QVariantList() 
) [virtual]
QString qx::QxSqlQuery::getJoinQuery ( const QString &  relationKey,
const QString &  relationAlias 
)
QString qx::QxSqlQuery::getJoinQueryHash ( )
QVector<QString> qx::QxSqlQuery::getSqlResultAllColumns ( ) const
QVariant qx::QxSqlQuery::getSqlResultAt ( long  row,
long  column 
) const
QVariant qx::QxSqlQuery::getSqlResultAt ( long  row,
const QString &  column,
bool  caseSensitive = false 
) const
QVector<QVariant> qx::QxSqlQuery::getSqlResultAt ( long  row) const
long qx::QxSqlQuery::getSqlResultColumnCount ( ) const
long qx::QxSqlQuery::getSqlResultRowCount ( ) const
virtual QxSqlQuery& qx::QxSqlQuery::groupBy ( const QStringList &  columns) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::groupBy ( const QString &  col1) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::groupBy ( const QString &  col1,
const QString &  col2 
) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::groupBy ( const QString &  col1,
const QString &  col2,
const QString &  col3 
) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::groupBy ( const QString &  col1,
const QString &  col2,
const QString &  col3,
const QString &  col4 
) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::groupBy ( const QString &  col1,
const QString &  col2,
const QString &  col3,
const QString &  col4,
const QString &  col5 
) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::groupBy ( const QString &  col1,
const QString &  col2,
const QString &  col3,
const QString &  col4,
const QString &  col5,
const QString &  col6 
) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::groupBy ( const QString &  col1,
const QString &  col2,
const QString &  col3,
const QString &  col4,
const QString &  col5,
const QString &  col6,
const QString &  col7 
) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::groupBy ( const QString &  col1,
const QString &  col2,
const QString &  col3,
const QString &  col4,
const QString &  col5,
const QString &  col6,
const QString &  col7,
const QString &  col8 
) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::groupBy ( const QString &  col1,
const QString &  col2,
const QString &  col3,
const QString &  col4,
const QString &  col5,
const QString &  col6,
const QString &  col7,
const QString &  col8,
const QString &  col9 
) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::in ( const QVariantList &  values) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::in ( const QVariant &  val1) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::in ( const QVariant &  val1,
const QVariant &  val2 
) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::in ( const QVariant &  val1,
const QVariant &  val2,
const QVariant &  val3 
) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::in ( const QVariant &  val1,
const QVariant &  val2,
const QVariant &  val3,
const QVariant &  val4 
) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::in ( const QVariant &  val1,
const QVariant &  val2,
const QVariant &  val3,
const QVariant &  val4,
const QVariant &  val5 
) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::in ( const QVariant &  val1,
const QVariant &  val2,
const QVariant &  val3,
const QVariant &  val4,
const QVariant &  val5,
const QVariant &  val6 
) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::in ( const QVariant &  val1,
const QVariant &  val2,
const QVariant &  val3,
const QVariant &  val4,
const QVariant &  val5,
const QVariant &  val6,
const QVariant &  val7 
) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::in ( const QVariant &  val1,
const QVariant &  val2,
const QVariant &  val3,
const QVariant &  val4,
const QVariant &  val5,
const QVariant &  val6,
const QVariant &  val7,
const QVariant &  val8 
) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::in ( const QVariant &  val1,
const QVariant &  val2,
const QVariant &  val3,
const QVariant &  val4,
const QVariant &  val5,
const QVariant &  val6,
const QVariant &  val7,
const QVariant &  val8,
const QVariant &  val9 
) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::in_Select ( const QxSqlQuery query) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::isBetween ( const QVariant &  val1,
const QVariant &  val2 
) [virtual]
bool qx::QxSqlQuery::isDistinct ( ) const
bool qx::QxSqlQuery::isEmpty ( ) const
virtual QxSqlQuery& qx::QxSqlQuery::isEqualTo ( const QVariant &  val) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::isEqualTo_Select ( const QxSqlQuery query) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::isGreaterThan ( const QVariant &  val) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::isGreaterThanOrEqualTo ( const QVariant &  val) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::isLessThan ( const QVariant &  val) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::isLessThanOrEqualTo ( const QVariant &  val) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::isNotBetween ( const QVariant &  val1,
const QVariant &  val2 
) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::isNotEqualTo ( const QVariant &  val) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::isNotEqualTo_Select ( const QxSqlQuery query) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::isNotNull ( ) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::isNull ( ) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::like ( const QString &  val) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::limit ( int  rowsCount,
int  startRow = 0,
bool  withTies = false 
) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::notIn ( const QVariantList &  values) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::notIn ( const QVariant &  val1) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::notIn ( const QVariant &  val1,
const QVariant &  val2 
) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::notIn ( const QVariant &  val1,
const QVariant &  val2,
const QVariant &  val3 
) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::notIn ( const QVariant &  val1,
const QVariant &  val2,
const QVariant &  val3,
const QVariant &  val4 
) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::notIn ( const QVariant &  val1,
const QVariant &  val2,
const QVariant &  val3,
const QVariant &  val4,
const QVariant &  val5 
) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::notIn ( const QVariant &  val1,
const QVariant &  val2,
const QVariant &  val3,
const QVariant &  val4,
const QVariant &  val5,
const QVariant &  val6 
) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::notIn ( const QVariant &  val1,
const QVariant &  val2,
const QVariant &  val3,
const QVariant &  val4,
const QVariant &  val5,
const QVariant &  val6,
const QVariant &  val7 
) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::notIn ( const QVariant &  val1,
const QVariant &  val2,
const QVariant &  val3,
const QVariant &  val4,
const QVariant &  val5,
const QVariant &  val6,
const QVariant &  val7,
const QVariant &  val8 
) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::notIn ( const QVariant &  val1,
const QVariant &  val2,
const QVariant &  val3,
const QVariant &  val4,
const QVariant &  val5,
const QVariant &  val6,
const QVariant &  val7,
const QVariant &  val8,
const QVariant &  val9 
) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::notIn_Select ( const QxSqlQuery query) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::notLike ( const QString &  val) [virtual]
void qx::QxSqlQuery::onBeforeSqlPrepare ( QString &  sql)
virtual QxSqlQuery& qx::QxSqlQuery::openParenthesis ( ) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::or_ ( const QString &  column) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::or_OpenParenthesis ( const QString &  column) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::orderAsc ( const QStringList &  columns) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::orderAsc ( const QString &  col1) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::orderAsc ( const QString &  col1,
const QString &  col2 
) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::orderAsc ( const QString &  col1,
const QString &  col2,
const QString &  col3 
) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::orderAsc ( const QString &  col1,
const QString &  col2,
const QString &  col3,
const QString &  col4 
) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::orderAsc ( const QString &  col1,
const QString &  col2,
const QString &  col3,
const QString &  col4,
const QString &  col5 
) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::orderAsc ( const QString &  col1,
const QString &  col2,
const QString &  col3,
const QString &  col4,
const QString &  col5,
const QString &  col6 
) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::orderAsc ( const QString &  col1,
const QString &  col2,
const QString &  col3,
const QString &  col4,
const QString &  col5,
const QString &  col6,
const QString &  col7 
) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::orderAsc ( const QString &  col1,
const QString &  col2,
const QString &  col3,
const QString &  col4,
const QString &  col5,
const QString &  col6,
const QString &  col7,
const QString &  col8 
) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::orderAsc ( const QString &  col1,
const QString &  col2,
const QString &  col3,
const QString &  col4,
const QString &  col5,
const QString &  col6,
const QString &  col7,
const QString &  col8,
const QString &  col9 
) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::orderDesc ( const QStringList &  columns) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::orderDesc ( const QString &  col1) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::orderDesc ( const QString &  col1,
const QString &  col2 
) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::orderDesc ( const QString &  col1,
const QString &  col2,
const QString &  col3 
) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::orderDesc ( const QString &  col1,
const QString &  col2,
const QString &  col3,
const QString &  col4 
) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::orderDesc ( const QString &  col1,
const QString &  col2,
const QString &  col3,
const QString &  col4,
const QString &  col5 
) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::orderDesc ( const QString &  col1,
const QString &  col2,
const QString &  col3,
const QString &  col4,
const QString &  col5,
const QString &  col6 
) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::orderDesc ( const QString &  col1,
const QString &  col2,
const QString &  col3,
const QString &  col4,
const QString &  col5,
const QString &  col6,
const QString &  col7 
) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::orderDesc ( const QString &  col1,
const QString &  col2,
const QString &  col3,
const QString &  col4,
const QString &  col5,
const QString &  col6,
const QString &  col7,
const QString &  col8 
) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::orderDesc ( const QString &  col1,
const QString &  col2,
const QString &  col3,
const QString &  col4,
const QString &  col5,
const QString &  col6,
const QString &  col7,
const QString &  col8,
const QString &  col9 
) [virtual]
void qx::QxSqlQuery::postProcess ( QString &  sql) const
QString qx::QxSqlQuery::query ( )
QxSqlQuery& qx::QxSqlQuery::query ( const QString &  sQuery)
QString qx::QxSqlQuery::queryAt ( int  idx) const
void qx::QxSqlQuery::queryAt ( int  idx,
const QString &  query 
)
void qx::QxSqlQuery::resolve ( QSqlQuery &  query,
qx::QxCollection< QString, QVariantList > *  pLstExecBatch = NULL 
) const
void qx::QxSqlQuery::resolveOutput ( QSqlQuery &  query,
bool  bFetchSqlResult 
)
QVariant qx::QxSqlQuery::response ( ) const
QxSqlQuery& qx::QxSqlQuery::setFctOnBeforeSqlPrepare ( type_fct_on_before_sql_prepare  fct)
void qx::QxSqlQuery::setResponse ( const QVariant &  v)
void qx::QxSqlQuery::setType ( const QString &  s)
virtual QxSqlQuery& qx::QxSqlQuery::startsWith ( const QString &  val) [virtual]
QString qx::QxSqlQuery::type ( ) const
void qx::QxSqlQuery::verifyQuery ( ) const [private]
virtual QxSqlQuery& qx::QxSqlQuery::where ( const QString &  column) [virtual]
virtual QxSqlQuery& qx::QxSqlQuery::where_OpenParenthesis ( const QString &  column) [virtual]

Friends And Related Function Documentation

template<class Archive >
void boost::serialization::qx_load ( Archive &  ar,
qx::QxSqlQuery t,
const unsigned int  file_version 
) [friend]
template<class Archive >
void boost::serialization::qx_save ( Archive &  ar,
const qx::QxSqlQuery t,
const unsigned int  file_version 
) [friend]
QX_DLL_EXPORT QDataStream& operator<< ( QDataStream &  stream,
const qx::QxSqlQuery t 
) [friend]
QX_DLL_EXPORT QDataStream& operator>> ( QDataStream &  stream,
qx::QxSqlQuery t 
) [friend]

Definition at line 257 of file QxSqlQuery.h.

QX_DLL_EXPORT qx_bool qx::cvt::detail::QxConvert_FromJson_Helper ( const QJsonValue &  j,
qx::QxSqlQuery t,
const QString &  format 
) [friend]

Definition at line 256 of file QxSqlQuery.h.

QX_DLL_EXPORT QJsonValue qx::cvt::detail::QxConvert_ToJson_Helper ( const qx::QxSqlQuery t,
const QString &  format 
) [friend]

Member Data Documentation

bool qx::QxSqlQuery::m_bDistinct [protected]

Replace SELECT by SELECT DISTINCT in SQL query.

Definition at line 279 of file QxSqlQuery.h.

Custom callback function to modify SQL query before preparing in database.

Definition at line 285 of file QxSqlQuery.h.

Current parenthesis count.

Definition at line 278 of file QxSqlQuery.h.

Current index of SQL element.

Definition at line 277 of file QxSqlQuery.h.

QList<std::shared_ptr<QxSqlQuery> > qx::QxSqlQuery::m_lstJoinQueryToResolve [protected]

List of SQL queries to resolve (in the right order) to add inside relationships joins (LEFT OUTER JOIN, INNER JOIN), for example : INNER JOIN my_table2 m2 ON (m1.id = m2.parent_id AND (XXX))

Definition at line 284 of file QxSqlQuery.h.

QHash<QString, std::shared_ptr<QxSqlQuery> > qx::QxSqlQuery::m_lstJoinQueryUser [protected]

List of SQL queries defined by user to add inside relationships joins (LEFT OUTER JOIN, INNER JOIN), for example : INNER JOIN my_table2 m2 ON (m1.id = m2.parent_id AND (XXX))

Definition at line 283 of file QxSqlQuery.h.

List of all SQL elements to build SQL query.

Definition at line 276 of file QxSqlQuery.h.

Bind value in this array.

Definition at line 274 of file QxSqlQuery.h.

Temporary SQL element.

Definition at line 275 of file QxSqlQuery.h.

std::shared_ptr<QxSqlResult> qx::QxSqlQuery::m_pSqlResult [protected]

All results returning by SQL query or stored procedure (after calling qx::dao::call_query function)

Definition at line 280 of file QxSqlQuery.h.

QStringList qx::QxSqlQuery::m_sQuery [protected]

Query SQL with place-holder.

Definition at line 273 of file QxSqlQuery.h.

QString qx::QxSqlQuery::m_sType [protected]

Query type (for example : 'aggregate' or 'cursor' for MongoDB database)

Definition at line 282 of file QxSqlQuery.h.

QVariant qx::QxSqlQuery::m_vResponse [protected]

Can be used to store some responses (from MongoDB database for example in JSON format)

Definition at line 281 of file QxSqlQuery.h.


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