KDb

KDbPreparedStatementInterface.h
1 /* This file is part of the KDE project
2  Copyright (C) 2008-2010 JarosÅ‚aw Staniek <[email protected]>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License as published by the Free Software Foundation; either
7  version 2 of the License, or (at your option) any later version.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18 */
19 
20 #ifndef KDB_PREPAREDSTATEMENT_IFACE_H
21 #define KDB_PREPAREDSTATEMENT_IFACE_H
22 
23 #include <QSharedData>
24 
25 #include "KDbResult.h"
26 #include "KDbPreparedStatement.h"
27 
28 class KDbSqlResult;
29 
30 //! Prepared statement interface for backend-dependent implementations.
32 {
33 protected:
35  ~KDbPreparedStatementInterface() override {}
36 
37  /*! For implementation. Initializes the prepared statement in a backend-dependent way
38  using recently generated @a sql statement.
39  It should be guaranteed that @a sql is valid and not empty.
40  For example sqlite3_prepare() is used for SQLite.
41  This is called only when d->dirty == true is encountered on execute(),
42  i.e. when attributes of the object (like WHERE field names) change. */
43  virtual bool prepare(const KDbEscapedString& sql) = 0;
44 
45  //! For implementation, executes the prepared statement
46  //! Type of statement is specified by the @a type parameter.
47  //! @a selectFieldList specifies fields for SELECT statement.
48  //! @a insertFieldList is set to list of fields in INSERT statement.
49  //! Parameters @a parameters are passed to the statement, usually using binding.
50  virtual QSharedPointer<KDbSqlResult> execute(
52  const KDbField::List& selectFieldList,
53  KDbFieldList* insertFieldList,
54  const KDbPreparedStatementParameters& parameters) /*Q_REQUIRED_RESULT*/ = 0;
55 
56  friend class KDbConnection;
57  friend class KDbPreparedStatement;
58 private:
59  Q_DISABLE_COPY(KDbPreparedStatementInterface)
60 };
61 
62 #endif
The KDbSqlResult class abstracts result of a raw SQL query preparation by KDbConnection::prepareSql()
Definition: KDbSqlResult.h:44
Specialized string for escaping.
Interface for classes providing a result.
Type
Defines type of the prepared statement.
Prepared statement interface for backend-dependent implementations.
Prepared database command for optimizing sequences of multiple database actions.
Provides database connection, allowing queries and data modification.
Definition: KDbConnection.h:51
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Oct 1 2023 04:09:03 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.