EasyQtSql
Easy SQL data access helper for QtSql
EasyQtSql_NonQueryResult.h
Go to the documentation of this file.
1 #ifndef EASYQTSQL_NONQUERYRESULT_H
2 #define EASYQTSQL_NONQUERYRESULT_H
3 
4 /*
5  * The MIT License (MIT)
6  * Copyright 2018 Alexey Kramin
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining
9  * a copy of this software and associated documentation files (the
10  * "Software"), to deal in the Software without restriction, including
11  * without limitation the rights to use, copy, modify, merge, publish,
12  * distribute, sublicense, and/or sell copies of the Software, and to
13  * permit persons to whom the Software is furnished to do so, subject to
14  * the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be
17  * included in all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
23  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
24  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26  *
27 */
28 
29 #ifndef EASY_QT_SQL_MAIN
30 
31 #include <QtSql>
32 
33 #endif
34 
39 {
40  friend class Database;
41  friend class Transaction;
42  friend class InsertQuery;
43  friend class UpdateQuery;
44  friend class DeleteQuery;
45 
46 public:
47 
51  QSqlQuery &unwrappedQuery()
52  {
53  return m_query;
54  }
55 
61  int numRowsAffected() const
62  {
63  return m_query.numRowsAffected();
64  }
65 
71  QVariant lastInsertId() const
72  {
73  return m_query.lastInsertId();
74  }
75 
81  QSqlError lastError() const
82  {
83  return m_query.lastError();
84  }
85 
91  QString lastQuery() const
92  {
93  return m_query.lastQuery();
94  }
95 
101  QString executedQuery() const
102  {
103  return m_query.executedQuery();
104  }
105 
106 private:
107  explicit NonQueryResult(const QSqlQuery &q)
108  : m_query(q)
109  { }
110 
111  QSqlQuery m_query;
112 };
113 
114 #endif // EASYQTSQL_NONQUERYRESULT_H
QSqlError lastError() const
Returns error information about the last error (if any) that occurred with this query.
Definition: EasyQtSql_NonQueryResult.h:81
QString lastQuery() const
Returns the text of the current query being used, or an empty string if there is no current query tex...
Definition: EasyQtSql_NonQueryResult.h:91
QVariant lastInsertId() const
Returns the object ID of the most recent inserted row if the database supports it.
Definition: EasyQtSql_NonQueryResult.h:71
QSqlQuery & unwrappedQuery()
Returns reference on wrapped QSqlQuery.
Definition: EasyQtSql_NonQueryResult.h:51
QSqlQuery wrapper for non-select query results reading.
Definition: EasyQtSql_NonQueryResult.h:38
QSqlDatabase wrapper.
Definition: EasyQtSql_Transaction.h:67
QSqlQuery wrapper for DELETE FROM ... WHERE .. query execution.
Definition: EasyQtSql_DeleteQuery.h:39
QSqlDatabase transaction wrapper.
Definition: EasyQtSql_Transaction.h:398
int numRowsAffected() const
Returns the number of rows affected by the result&#39;s SQL statement, or -1 if it cannot be determined...
Definition: EasyQtSql_NonQueryResult.h:61
QString executedQuery() const
Returns the last query that was successfully executed.
Definition: EasyQtSql_NonQueryResult.h:101
QSqlQuery wrapper for INSERT INTO table query execution.
Definition: EasyQtSql_InsertQuery.h:39
QSqlQuery wrapper for UPDATE ... SET ... WHERE ... query execution.
Definition: EasyQtSql_UpdateQuery.h:39