sptk2 logo
SPTK Home Page
InsertQuery.h
1/*
2╔══════════════════════════════════════════════════════════════════════════════╗
3║ SIMPLY POWERFUL TOOLKIT (SPTK) ║
4╟──────────────────────────────────────────────────────────────────────────────╢
5║ copyright © 1999-2022 Alexey Parshin. All rights reserved. ║
6║ email alexeyp@gmail.com ║
7╚══════════════════════════════════════════════════════════════════════════════╝
8┌──────────────────────────────────────────────────────────────────────────────┐
9│ This library is free software; you can redistribute it and/or modify it │
10│ under the terms of the GNU Library General Public License as published by │
11│ the Free Software Foundation; either version 2 of the License, or (at your │
12│ option) any later version. │
13│ │
14│ This library is distributed in the hope that it will be useful, but │
15│ WITHOUT ANY WARRANTY; without even the implied warranty of │
16│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library │
17│ General Public License for more details. │
18│ │
19│ You should have received a copy of the GNU Library General Public License │
20│ along with this library; if not, write to the Free Software Foundation, │
21│ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. │
22│ │
23│ Please report all bugs and problems to alexeyp@gmail.com. │
24└──────────────────────────────────────────────────────────────────────────────┘
25*/
26
27#pragma once
28
29#include <sptk5/db/Query.h>
30
31namespace sptk {
43class SP_EXPORT InsertQuery : public Query
44{
45public:
57 explicit InsertQuery(const DatabaseConnection& db, const String& sql = "", const String& idFieldName = "id");
58
63 String sql() const override;
64
71 void sql(const String& _sql) override;
72
78 void exec() override;
79
86 void exec(const String& newSQL) override
87 {
88 sql(newSQL);
89 open();
90 }
91
96 uint64_t id() const
97 {
98 return m_id;
99 }
100
101private:
102 uint64_t m_id {0};
103 String m_idFieldName;
104 SQuery m_lastInsertedId;
105
113 static String reviewQuery(DatabaseConnectionType connectionType, const String& sql, const String& idFieldName);
114};
115
116} // namespace sptk
Definition: InsertQuery.h:44
Definition: Query.h:239
Definition: String.h:49
uint64_t id() const
Definition: InsertQuery.h:96
void sql(const String &_sql) override
InsertQuery(const DatabaseConnection &db, const String &sql="", const String &idFieldName="id")
DatabaseConnectionType
Definition: PoolDatabaseConnection.h:55
void exec() override
void exec(const String &newSQL) override
Definition: InsertQuery.h:86
String sql() const override

Fri Oct 14 2022 09:58:31: SPTK 5.4.1