KDb

PostgresqlPreparedStatement.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2005 Adam Pigg <adam@piggz.co.uk>
3 Copyright (C) 2010-2012 Jarosław Staniek <staniek@kde.org>
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this program; see the file COPYING. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19*/
20
21#include "PostgresqlPreparedStatement.h"
22#include "KDbConnection.h"
23
24PostgresqlPreparedStatement::PostgresqlPreparedStatement(PostgresqlConnectionInternal* conn)
26 , PostgresqlConnectionInternal(conn->connection)
27{
28}
29
30
31PostgresqlPreparedStatement::~PostgresqlPreparedStatement()
32{
33}
34
35bool PostgresqlPreparedStatement::prepare(const KDbEscapedString& sql)
36{
37 Q_UNUSED(sql);
38 return true;
39}
40
41QSharedPointer<KDbSqlResult> PostgresqlPreparedStatement::execute(
42 KDbPreparedStatement::Type type, const KDbField::List &selectFieldList,
43 KDbFieldList *insertFieldList, const KDbPreparedStatementParameters &parameters)
44{
45 Q_UNUSED(selectFieldList);
48 const int missingValues = insertFieldList->fieldCount() - parameters.count();
49 KDbPreparedStatementParameters myParameters(parameters);
50 if (missingValues > 0) {
51 //! @todo can be more efficient
52 for (int i = 0; i < missingValues; i++) {
53 myParameters.append(QVariant());
54 }
55 }
56 result = connection->insertRecord(insertFieldList, myParameters);
57 }
58//! @todo support select
59 return result;
60}
Specialized string for escaping.
int fieldCount() const
Prepared statement interface for backend-dependent implementations.
Type
Defines type of the prepared statement.
@ InsertStatement
INSERT statement will be prepared end executed.
qsizetype count() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jul 19 2024 12:00:07 by doxygen 1.11.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.