KDb

PostgresqlPreparedStatement.cpp
1 /* This file is part of the KDE project
2  Copyright (C) 2005 Adam Pigg <[email protected]>
3  Copyright (C) 2010-2012 Jarosław Staniek <[email protected]>
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 
24 PostgresqlPreparedStatement::PostgresqlPreparedStatement(PostgresqlConnectionInternal* conn)
26  , PostgresqlConnectionInternal(conn->connection)
27 {
28 }
29 
30 
31 PostgresqlPreparedStatement::~PostgresqlPreparedStatement()
32 {
33 }
34 
35 bool PostgresqlPreparedStatement::prepare(const KDbEscapedString& sql)
36 {
37  Q_UNUSED(sql);
38  return true;
39 }
40 
41 QSharedPointer<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 }
@ InsertStatement
INSERT statement will be prepared end executed.
int count(const T &value) const const
Specialized string for escaping.
Type
Defines type of the prepared statement.
Prepared statement interface for backend-dependent implementations.
int fieldCount() const
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sat Jun 25 2022 06:21:34 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.