KDb

KDbNativeStatementBuilder.h
1/* This file is part of the KDE project
2 Copyright (C) 2003-2016 Jarosław Staniek <staniek@kde.org>
3
4 This program 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 program 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 program; see the file COPYING. 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_KDBNATIVESTATEMENTBUILDER_H
21#define KDB_KDBNATIVESTATEMENTBUILDER_H
22
23#include "KDb.h"
24#include "KDbSelectStatementOptions.h"
25
26//! A builder for generating various types of native SQL statements
27/*! The statement strings can be specific for the used connection and database driver,
28 and thus generally not portable across connections. */
30{
31public:
32 /**
33 * Creates a new native builder object. @a connection is required.
34 *
35 * If @a dialect is KDbEscaping generated statement strings will be of KDbSQL dialect,
36 * else they will be specific to database connection or connection's database driver.
37 */
39
41
42 /*! Generates a native "SELECT ..." statement string that can be used for executing
43 query defined by @a querySchema, @a params and @a options.
44
45 @a target and @a querySchema must not be 0. The statement is written to @ref *target on success.
46 @return true on success. */
47 bool generateSelectStatement(KDbEscapedString *target, KDbQuerySchema* querySchema,
48 const KDbSelectStatementOptions& options,
49 const QList<QVariant>& parameters = QList<QVariant>()) const;
50
51 /*! @overload generateSelectStatement(KDbEscapedString *target, KDbQuerySchema* querySchema,
52 const KDbSelectStatementOptions& options,
53 const QList<QVariant>& parameters) const. */
54 bool generateSelectStatement(KDbEscapedString *target,
55 KDbQuerySchema* querySchema,
56 const QList<QVariant>& parameters = QList<QVariant>()) const;
57
58 /*! Generates a native "SELECT ..." statement string that can be used for executing
59 query defined by an functional equivalent of a "SELECT * FROM table_name" statement
60 where <i>table_name</i> is @a tableSchema's name. @a params and @a options are used
61 like in the
62 @ref toSelectStatement(KDbEscapedString*, KDbQuerySchema*, const KDbSelectStatementOptions&, const QList<QVariant>&)
63 variant.
64 @a target and @a querySchema must not be 0.
65 @return true on success. */
66 bool generateSelectStatement(KDbEscapedString *target, KDbTableSchema* tableSchema,
68
69 /*! Generates a native "CREATE TABLE ..." statement string that can be used for creation
70 of @a tableSchema in the database. The statement is written to @ref *target on success.
71 @return true on success.
72 If @a target is @c nullptr, @c false is returned.
73 */
74 bool generateCreateTableStatement(KDbEscapedString *target,
75 const KDbTableSchema& tableSchema) const;
76
77private:
78 Q_DISABLE_COPY(KDbNativeStatementBuilder)
79 class Private;
80 Private * const d;
81};
82
83#endif
Provides database connection, allowing queries and data modification.
Specialized string for escaping.
A builder for generating various types of native SQL statements.
KDbQuerySchema provides information about database query.
Options used in KDbNativeStatementBuilder::generateSelectStatement()
IdentifierEscapingType
Escaping type for identifiers.
Definition KDbGlobal.h:144
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:38:30 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.