Sayonara Player
Query.h
1 /* Query.h */
2 
3 /* Copyright (C) 2011-2017 Lucio Carreras
4  *
5  * This file is part of sayonara player
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11 
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16 
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef Query_H
22 #define Query_H
23 
24 #include "Utils/Pimpl.h"
25 
26 #include <QString>
27 #include <QSqlQuery>
28 #include <QVariant>
29 #include <QSqlDatabase>
30 #include <QSqlError>
31 
32 namespace DB
33 {
34  class Module;
35  class Query :
36  public QSqlQuery
37  {
38  PIMPL(Query)
39 
40  private:
41  explicit Query(const QString& query=QString(), const QSqlDatabase& db = QSqlDatabase()) = delete;
42  explicit Query(QSqlResult* result) = delete;
43  explicit Query(QSqlDatabase db);
44 
45  public:
46  explicit Query(const Module* module);
47  Query(const QString& connection_name, DbId db_id);
48  Query(const Query& other);
49  Query& operator=(const Query& other);
50 
51  virtual ~Query();
52 
53  bool prepare(const QString& query);
54  void bindValue(const QString & placeholder, const QVariant & val, QSql::ParamType paramType = QSql::In);
55  bool exec();
56  void set_error(bool b);
57  bool has_error() const;
58 
59  QString get_query_string() const;
60  void show_query() const;
61  void show_error(const QString& err_msg) const;
62 
63 
64  size_t fetched_rows();
65  };
66 }
67 
68 #endif // Query_H
Definition: Module.h:32
Definition: Query.h:35
Definition: Albums.h:31