KDb

KDbPreparedStatementInterface.h
1/* This file is part of the KDE project
2 Copyright (C) 2008-2010 Jarosław Staniek <staniek@kde.org>
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
28class KDbSqlResult;
29
30//! Prepared statement interface for backend-dependent implementations.
32{
33protected:
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.
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;
58private:
59 Q_DISABLE_COPY(KDbPreparedStatementInterface)
60};
61
62#endif
Provides database connection, allowing queries and data modification.
Specialized string for escaping.
Prepared statement interface for backend-dependent implementations.
virtual bool prepare(const KDbEscapedString &sql)=0
virtual QSharedPointer< KDbSqlResult > execute(KDbPreparedStatement::Type type, const KDbField::List &selectFieldList, KDbFieldList *insertFieldList, const KDbPreparedStatementParameters &parameters)=0
For implementation, executes the prepared statement Type of statement is specified by the type parame...
Prepared database command for optimizing sequences of multiple database actions.
Type
Defines type of the prepared statement.
Interface for classes providing a result.
The KDbSqlResult class abstracts result of a raw SQL query preparation by KDbConnection::prepareSql()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 17 2024 11:56:02 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.