KDb

MysqlConnection.h
1 /* This file is part of the KDE project
2  Copyright (C) 2002 Lucijan Busch <[email protected]>
3  Copyright (C) 2003 Joseph Wenninger<[email protected]>
4  Copyright (C) 2004-2016 JarosÅ‚aw Staniek <[email protected]>
5 
6  This program is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Library General Public
8  License as published by the Free Software Foundation; either
9  version 2 of the License, or (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Library General Public License for more details.
15 
16  You should have received a copy of the GNU Library General Public License
17  along with this program; see the file COPYING. If not, write to
18  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20 */
21 
22 #ifndef KDB_MYSQLCONNECTION_H
23 #define KDB_MYSQLCONNECTION_H
24 
25 #include <QStringList>
26 
27 #include "KDbConnection.h"
28 
29 class MysqlConnectionInternal;
30 
31 /*! @short Provides database connection, allowing queries and data modification.
32 */
34 {
35  Q_DECLARE_TR_FUNCTIONS(MysqlConnection)
36 public:
37  ~MysqlConnection() override;
38 
39  Q_REQUIRED_RESULT KDbCursor *prepareQuery(const KDbEscapedString &sql,
41  = KDbCursor::Option::None) override;
42  Q_REQUIRED_RESULT KDbCursor *prepareQuery(KDbQuerySchema *query,
44  = KDbCursor::Option::None) override;
45 
46  Q_REQUIRED_RESULT KDbPreparedStatementInterface *prepareStatementInternal() override;
47 
48 protected:
49  /*! Used by driver */
52 
53  bool drv_connect() override;
55  bool drv_disconnect() override;
56  bool drv_getDatabasesList(QStringList* list) override;
57  //! reimplemented using "SHOW DATABASES LIKE..." because MySQL stores db names in lower case.
58  bool drv_databaseExists(const QString &dbName, bool ignoreErrors = true) override;
59  bool drv_createDatabase(const QString &dbName = QString()) override;
60  bool drv_useDatabase(const QString &dbName = QString(), bool *cancelled = nullptr,
61  KDbMessageHandler* msgHandler = nullptr) override;
62  bool drv_closeDatabase() override;
63  bool drv_dropDatabase(const QString &dbName = QString()) override;
64  Q_REQUIRED_RESULT KDbSqlResult *drv_prepareSql(const KDbEscapedString &sql) override;
65  bool drv_executeSql(const KDbEscapedString& sql) override;
66 
67  //! Implemented for KDbResultable
68  QString serverResultName() const override;
69 
70 //! @todo move this somewhere to low level class (MIGRATION?)
71  tristate drv_containsTable(const QString &tableName) override;
72 
73  void storeResult();
74 
75  MysqlConnectionInternal* const d;
76 
77  friend class MysqlDriver;
78  friend class MysqlCursorData;
79  friend class MysqlSqlResult;
80 private:
81  Q_DISABLE_COPY(MysqlConnection)
82 };
83 
84 #endif
bool drv_getServerVersion(KDbServerVersionInfo *version) override
Provides database cursor functionality.
Definition: KDbCursor.h:68
The KDbSqlResult class abstracts result of a raw SQL query preparation by KDbConnection::prepareSql()
Definition: KDbSqlResult.h:44
QString serverResultName() const override
Implemented for KDbResultable.
Specialized string for escaping.
Database driver's abstraction.
Definition: KDbDriver.h:49
tristate drv_containsTable(const QString &tableName) override
bool drv_executeSql(const KDbEscapedString &sql) override
Executes query for a raw SQL statement sql without returning resulting records.
bool drv_getDatabasesList(QStringList *list) override
bool drv_connect() override
bool drv_createDatabase(const QString &dbName=QString()) override
bool drv_disconnect() override
3-state logical type with three values: true, false and cancelled and convenient operators.
Definition: KDbTristate.h:100
bool drv_dropDatabase(const QString &dbName=QString()) override
bool drv_useDatabase(const QString &dbName=QString(), bool *cancelled=nullptr, KDbMessageHandler *msgHandler=nullptr) override
KDbSqlResult * drv_prepareSql(const KDbEscapedString &sql) override
Prepares query for a raw SQL statement sql with possibility of returning records.
Prepared statement interface for backend-dependent implementations.
KDbQuerySchema provides information about database query.
unsigned int version()
Definition: KDb.cpp:336
KDbConnectionOptions * options()
Database specific connection data, e.g. host, port.
bool drv_closeDatabase() override
Generic options for a single connection. The options are accessible using key/value pairs....
Provides database connection, allowing queries and data modification.
Definition: KDbConnection.h:51
KDbDriver * driver() const
bool drv_databaseExists(const QString &dbName, bool ignoreErrors=true) override
reimplemented using "SHOW DATABASES LIKE..." because MySQL stores db names in lower case.
KDbPreparedStatementInterface * prepareStatementInternal() override
KDbCursor * prepareQuery(const KDbEscapedString &sql, KDbCursor::Options options=KDbCursor::Option::None) override
MysqlConnection(KDbDriver *driver, const KDbConnectionData &connData, const KDbConnectionOptions &options)
Provides database connection, allowing queries and data modification.
MySQL database driver.
Definition: MysqlDriver.h:29
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.