MysqlConnection
#include <MysqlConnection.h>
Protected Attributes | |
MysqlConnectionInternal *const | d |
Protected Attributes inherited from KDbResultable | |
Private *const | d |
KDbResult | m_result |
Additional Inherited Members | |
Public Types inherited from KDbConnection | |
enum class | AlterTableNameOption { Default = 0 , DropDestination = 1 } |
typedef QFlags< AlterTableNameOption > | AlterTableNameOptions |
enum class | CreateTableOption { Default = 0 , DropDestination = 1 } |
typedef QFlags< CreateTableOption > | CreateTableOptions |
enum class | QueryRecordOption { AddLimitTo1 = 1 , Default = AddLimitTo1 } |
typedef QFlags< QueryRecordOption > | QueryRecordOptions |
Static Public Member Functions inherited from KDbConnection | |
static QStringList | kdbSystemTableNames () |
Public Attributes inherited from KDbConnection | |
H_INS_REC_ALL | |
Detailed Description
Provides database connection, allowing queries and data modification.
Definition at line 33 of file MysqlConnection.h.
Constructor & Destructor Documentation
◆ ~MysqlConnection()
|
override |
Definition at line 39 of file MysqlConnection.cpp.
◆ MysqlConnection()
|
protected |
Used by driver
Definition at line 32 of file MysqlConnection.cpp.
Member Function Documentation
◆ drv_closeDatabase()
|
overrideprotectedvirtual |
For implementation: closes previously opened database using connection.
- Todo
- free resources, as far as I know, mysql doesn't support that
Implements KDbConnection.
Definition at line 163 of file MysqlConnection.cpp.
◆ drv_connect()
|
overrideprotectedvirtual |
For implementation: connects to database.
- Returns
- true on success.
Implements KDbConnection.
Definition at line 45 of file MysqlConnection.cpp.
◆ drv_containsTable()
- Todo
- move this somewhere to low level class (MIGRATION?)
Implements KDbConnection.
Definition at line 200 of file MysqlConnection.cpp.
◆ drv_createDatabase()
|
overrideprotectedvirtual |
For implementation: creates new database using connection
Implements KDbConnection.
Definition at line 141 of file MysqlConnection.cpp.
◆ drv_databaseExists()
|
overrideprotectedvirtual |
reimplemented using "SHOW DATABASES LIKE..." because MySQL stores db names in lower case.
Reimplemented from KDbConnection.
Definition at line 125 of file MysqlConnection.cpp.
◆ drv_disconnect()
|
overrideprotectedvirtual |
For implementation: disconnects database
- Returns
- true on success.
Implements KDbConnection.
Definition at line 93 of file MysqlConnection.cpp.
◆ drv_dropDatabase()
|
overrideprotectedvirtual |
For implementation: drops database from the server using connection. After drop, database shouldn't be accessible anymore.
- Todo
- is here escaping needed?
Implements KDbConnection.
Definition at line 169 of file MysqlConnection.cpp.
◆ drv_executeSql()
|
overrideprotectedvirtual |
Executes query for a raw SQL statement sql without returning resulting records.
It is useful mostly for INSERT queries but it is possible to execute SELECT queries when returned records can be ignored. The @sql should be is valid and properly escaped.
- Note
- Only use this method if you really need.
- See also
- executeSql
Implements KDbConnection.
Definition at line 186 of file MysqlConnection.cpp.
◆ drv_getDatabasesList()
|
overrideprotectedvirtual |
For reimplementation: loads list of databases' names available for this connection and adds these names to list. If your server is not able to offer such a list, consider reimplementing drv_databaseExists() instead. The method should return true only if there was no error on getting database names list from the server. Default implementation puts empty list into list and returns true.
- See also
- databaseNames
Reimplemented from KDbConnection.
Definition at line 108 of file MysqlConnection.cpp.
◆ drv_getServerVersion()
|
overrideprotectedvirtual |
For implementation: Sets version to real server's version. Depending on backend type this method is called after (if KDbDriverBehavior::USING_DATABASE_REQUIRED_TO_CONNECT is true) or before database is used (if KDbDriverBehavior::USING_DATABASE_REQUIRED_TO_CONNECT is false), i.e. for PostgreSQL it is called after. In any case it is called after successful drv_connect().
- Returns
- true on success.
- Todo
- this is hardcoded for now; define api for retrieving variables and use this API...
Implements KDbConnection.
Definition at line 67 of file MysqlConnection.cpp.
◆ drv_prepareSql()
|
overrideprotectedvirtual |
Prepares query for a raw SQL statement sql with possibility of returning records.
It is useful mostly for SELECT queries. While INSERT queries do not return records, the KDbSqlResult object offers KDbSqlResult::lastInsertRecordId(). The @sql should be is valid and properly escaped. Only use this method if you really need. For low-level access to the results (without cursors). The result may be not stored (not buffered) yet. Use KDbSqlResult::fetchRecord() to fetch each record.
- Returns
- Null pointer if there is no proper result or error. Ownership of the returned object is passed to the caller.
- See also
- prepareSql
- Todo
- use mysql_error()
Implements KDbConnection.
Definition at line 176 of file MysqlConnection.cpp.
◆ drv_useDatabase()
|
overrideprotectedvirtual |
For implementation: opens existing database using connection
- Returns
- true on success, false on failure; sets cancelled to true if this action has been cancelled.
- Todo
- is here escaping needed?
Implements KDbConnection.
Definition at line 150 of file MysqlConnection.cpp.
◆ prepareQuery() [1/2]
|
overridevirtual |
Prepares SELECT query described by a raw statement sql.
- Returns
- opened cursor created for results of this query or
nullptr
if there was any error. Ownership of the returned object is passed to the caller. KDbCursor can have optionally applied options (one of more selected from KDbCursor::Options). Preparation means that returned cursor is created but not opened. Open this when you would like to do it with KDbCursor::open().
Note for driver developers: you should initialize cursor engine-specific resources and return KDbCursor subclass' object (passing sql and options to its constructor).
Implements KDbConnection.
Definition at line 98 of file MysqlConnection.cpp.
◆ prepareQuery() [2/2]
|
overridevirtual |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Prepares query described by query schema without parameters.
Implements KDbConnection.
Definition at line 103 of file MysqlConnection.cpp.
◆ prepareStatementInternal()
|
overridevirtual |
Prepare an SQL statement and return a KDbPreparedStatementInterface-derived object. Ownership of the returned object is passed to the caller.
Implements KDbConnection.
Definition at line 206 of file MysqlConnection.cpp.
◆ serverResultName()
|
overrideprotectedvirtual |
Implemented for KDbResultable.
Reimplemented from KDbResultable.
Definition at line 195 of file MysqlConnection.cpp.
◆ storeResult()
|
protected |
Definition at line 211 of file MysqlConnection.cpp.
Member Data Documentation
◆ d
|
protected |
Definition at line 75 of file MysqlConnection.h.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:38:32 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.