KDbConnectionProxy

Search for usage in LXR

KDbConnectionProxy Class Reference

#include <KDbConnectionProxy.h>

Inheritance diagram for KDbConnectionProxy:

Public Member Functions

 KDbConnectionProxy (KDbConnection *connection)
 
 ~KDbConnectionProxy () override
 
tristate alterTable (KDbTableSchema *tableSchema, KDbTableSchema *newTableSchema)
 
bool alterTableName (KDbTableSchema *tableSchema, const QString &newName, AlterTableNameOptions options=AlterTableNameOption::Default)
 
QString anyAvailableDatabaseName () override
 
bool autoCommit () const
 
bool beginAutoCommitTransaction (KDbTransactionGuard *tg)
 
KDbTransaction beginTransaction ()
 
bool checkConnected ()
 
bool checkIfColumnExists (KDbCursor *cursor, int column)
 
bool checkIsDatabaseUsed ()
 
void clearResult ()
 
bool closeDatabase ()
 
bool commitAutoCommitTransaction (const KDbTransaction &trans)
 
bool commitTransaction (KDbTransaction trans=KDbTransaction(), KDbTransaction::CommitOptions options=KDbTransaction::CommitOptions())
 
bool connect ()
 
tristate containsTable (const QString &tableName)
 
bool copyDataBlock (int sourceObjectID, int destObjectID, const QString &dataID=QString())
 
KDbTableSchemacopyTable (const KDbTableSchema &tableSchema, const KDbObject &newData)
 
KDbTableSchemacopyTable (const QString &tableName, const KDbObject &newData)
 
bool createDatabase (const QString &dbName)
 
bool createTable (KDbTableSchema *tableSchema, CreateTableOptions options=CreateTableOption::Default)
 
QString currentDatabase () const
 
KDbConnectionData data () const
 
bool databaseExists (const QString &dbName, bool ignoreErrors=true)
 
QStringList databaseNames (bool also_system_db=false)
 
KDbProperties databaseProperties () const
 
KDbVersionInfo databaseVersion () const
 
KDbTransaction defaultTransaction () const
 
bool deleteAllRecords (KDbQuerySchema *query)
 
bool deleteCursor (KDbCursor *cursor)
 
bool deleteRecord (KDbQuerySchema *query, KDbRecordData *data, bool useRecordId=false)
 
bool disconnect ()
 
KDbDriverdriver () const
 
bool dropDatabase (const QString &dbName=QString())
 
bool dropQuery (const QString &queryName)
 
bool dropQuery (KDbQuerySchema *querySchema)
 
tristate dropTable (const QString &tableName)
 
tristate dropTable (KDbTableSchema *tableSchema)
 
tristate dropTableInternal (KDbTableSchema *tableSchema, bool alsoRemoveSchema)
 
bool drv_afterInsert (const QString &tableName, KDbFieldList *fields) override
 
bool drv_afterUpdate (const QString &tableName, KDbFieldList *fields) override
 
bool drv_alterTableName (KDbTableSchema *tableSchema, const QString &newName) override
 
bool drv_beforeInsert (const QString &tableName, KDbFieldList *fields) override
 
bool drv_beforeUpdate (const QString &tableName, KDbFieldList *fields) override
 
KDbTransactionDatadrv_beginTransaction () override
 
bool drv_closeDatabase () override
 
bool drv_commitTransaction (KDbTransactionData *trans) override
 
bool drv_connect () override
 
tristate drv_containsTable (const QString &tableName) override
 
bool drv_copyTableData (const KDbTableSchema &tableSchema, const KDbTableSchema &destinationTableSchema) override
 
bool drv_createDatabase (const QString &dbName=QString()) override
 
bool drv_createTable (const KDbTableSchema &tableSchema) override
 
bool drv_createTable (const QString &tableName) override
 
bool drv_databaseExists (const QString &dbName, bool ignoreErrors=true) override
 
bool drv_disconnect () override
 
bool drv_dropDatabase (const QString &dbName=QString()) override
 
bool drv_dropTable (const QString &tableName) override
 
bool drv_executeSql (const KDbEscapedString &sql) override
 
bool drv_getDatabasesList (QStringList *list) override
 
bool drv_getServerVersion (KDbServerVersionInfo *version) override
 
QStringList drv_getTableNames (bool *ok) override
 
bool drv_isDatabaseUsed () const override
 
KDbSqlResultdrv_prepareSql (const KDbEscapedString &sql) override
 
bool drv_rollbackTransaction (KDbTransactionData *trans) override
 
bool drv_setAutoCommit (bool on) override
 
bool drv_useDatabase (const QString &dbName=QString(), bool *cancelled=nullptr, KDbMessageHandler *msgHandler=nullptr) override
 
QString escapeIdentifier (const QString &id) const override
 
KDbEscapedString escapeString (const QString &str) const override
 
KDbCursorexecuteQuery (const KDbEscapedString &sql, KDbCursor::Options options=KDbCursor::Option::None)
 
KDbCursorexecuteQuery (KDbQuerySchema *query, const QList< QVariant > &params, KDbCursor::Options options=KDbCursor::Option::None)
 
KDbCursorexecuteQuery (KDbQuerySchema *query, KDbCursor::Options options=KDbCursor::Option::None)
 
KDbCursorexecuteQuery (KDbTableSchema *table, KDbCursor::Options options=KDbCursor::Option::None)
 
KDbCursorexecuteQueryInternal (const KDbEscapedString &sql, KDbQuerySchema *query, const QList< QVariant > *params)
 
bool executeSql (const KDbEscapedString &sql)
 
KDbFieldfindSystemFieldName (const KDbFieldList &fieldlist)
 
bool insertRecord (KDbFieldList *fields, const QList< QVariant > &values)
 
bool insertRecord (KDbQuerySchema *query, KDbRecordData *data, KDbRecordEditBuffer *buf, bool getRecordId=false)
 
bool insertRecord (KDbTableSchema *tableSchema, const QList< QVariant > &values)
 
bool isConnected () const
 
bool isDatabaseUsed () const
 
tristate isEmpty (KDbTableSchema *table)
 
bool isInternalTableSchema (const QString &tableName)
 
tristate loadDataBlock (int objectID, QString *dataString, const QString &dataID=QString())
 
bool loadExtendedTableSchemaData (KDbTableSchema *tableSchema)
 
tristate loadObjectData (int type, const QString &name, KDbObject *object)
 
tristate loadObjectData (int type, int id, KDbObject *object)
 
QList< int > objectIds (int objectType, bool *ok=nullptr)
 
QStringList objectNames (int objectType=KDb::AnyObjectType, bool *ok=nullptr)
 
KDbConnectionOptionsoptions ()
 
KDbConnectionparentConnection ()
 
const KDbConnectionparentConnection () const
 
KDbCursorprepareQuery (const KDbEscapedString &sql, KDbCursor::Options options=KDbCursor::Option::None) override
 
KDbCursorprepareQuery (KDbQuerySchema *query, KDbCursor::Options options=KDbCursor::Option::None) override
 
KDbCursorprepareQuery (KDbTableSchema *table, KDbCursor::Options options=KDbCursor::Option::None)
 
QSharedPointer< KDbSqlResultprepareSql (const KDbEscapedString &sql)
 
KDbPreparedStatement prepareStatement (KDbPreparedStatement::Type type, KDbFieldList *fields, const QStringList &whereFieldNames=QStringList())
 
KDbPreparedStatementInterfaceprepareStatementInternal () override
 
QList< int > queryIds (bool *ok=nullptr)
 
KDbQuerySchemaquerySchema (const QString &queryName)
 
KDbQuerySchemaquerySchema (int queryId)
 
tristate querySingleNumber (const KDbEscapedString &sql, int *number, int column=0, QueryRecordOptions options=QueryRecordOption::Default)
 
tristate querySingleNumber (KDbQuerySchema *query, int *number, const QList< QVariant > &params, int column=0, QueryRecordOptions options=QueryRecordOption::Default)
 
tristate querySingleNumber (KDbQuerySchema *query, int *number, int column=0, QueryRecordOptions options=QueryRecordOption::Default)
 
tristate querySingleNumberInternal (const KDbEscapedString *sql, int *number, KDbQuerySchema *query, const QList< QVariant > *params, int column, QueryRecordOptions options)
 
tristate querySingleRecord (const KDbEscapedString &sql, KDbRecordData *data, QueryRecordOptions options=QueryRecordOption::Default)
 
tristate querySingleRecord (KDbQuerySchema *query, KDbRecordData *data, const QList< QVariant > &params, QueryRecordOptions options=QueryRecordOption::Default)
 
tristate querySingleRecord (KDbQuerySchema *query, KDbRecordData *data, QueryRecordOptions options=QueryRecordOption::Default)
 
tristate querySingleRecordInternal (KDbRecordData *data, const KDbEscapedString *sql, KDbQuerySchema *query, const QList< QVariant > *params, QueryRecordOptions options)
 
tristate querySingleString (const KDbEscapedString &sql, QString *value, int column=0, QueryRecordOptions options=QueryRecordOption::Default)
 
tristate querySingleString (KDbQuerySchema *query, QString *value, const QList< QVariant > &params, int column=0, QueryRecordOptions options=QueryRecordOption::Default)
 
tristate querySingleString (KDbQuerySchema *query, QString *value, int column=0, QueryRecordOptions options=QueryRecordOption::Default)
 
tristate querySingleStringInternal (const KDbEscapedString *sql, QString *value, KDbQuerySchema *query, const QList< QVariant > *params, int column, QueryRecordOptions options)
 
bool queryStringList (const KDbEscapedString &sql, QStringList *list, int column=0)
 
bool queryStringList (KDbQuerySchema *query, QStringList *list, const QList< QVariant > &params, int column=0)
 
bool queryStringList (KDbQuerySchema *query, QStringList *list, int column=0)
 
bool queryStringListInternal (const KDbEscapedString *sql, QStringList *list, KDbQuerySchema *query, const QList< QVariant > *params, int column, bool(*filterFunction)(const QString &))
 
KDbEscapedString recentSqlString () const override
 
bool removeDataBlock (int objectID, const QString &dataID=QString())
 
bool removeObject (int objId)
 
KDbResult result () const
 
KDbResultable resultable () const
 
tristate resultExists (const KDbEscapedString &sql, QueryRecordOptions options=QueryRecordOption::Default)
 
bool rollbackAutoCommitTransaction (const KDbTransaction &trans)
 
bool rollbackTransaction (KDbTransaction trans=KDbTransaction(), KDbTransaction::CommitOptions options=KDbTransaction::CommitOptions())
 
KDbServerVersionInfo serverVersion () const
 
bool setAutoCommit (bool on)
 
void setAvailableDatabaseName (const QString &dbName)
 
void setDefaultTransaction (const KDbTransaction &trans)
 
void setParentConnectionIsOwned (bool set)
 
bool setQuerySchemaObsolete (const QString &queryName)
 
KDbFieldsetupField (const KDbRecordData &data)
 
bool setupObjectData (const KDbRecordData &data, KDbObject *object)
 
bool storeDataBlock (int objectID, const QString &dataString, const QString &dataID=QString())
 
bool storeExtendedTableSchemaData (KDbTableSchema *tableSchema)
 
bool storeMainFieldSchema (KDbField *field)
 
bool storeNewObjectData (KDbObject *object)
 
bool storeObjectData (KDbObject *object)
 
QList< int > tableIds (bool *ok=nullptr)
 
QStringList tableNames (bool alsoSystemTables=false, bool *ok=nullptr)
 
KDbTableSchematableSchema (const QString &tableName)
 
KDbTableSchematableSchema (int tableId)
 
QList< KDbTransactiontransactions ()
 
bool updateRecord (KDbQuerySchema *query, KDbRecordData *data, KDbRecordEditBuffer *buf, bool useRecordId=false)
 
bool useDatabase (const QString &dbName=QString(), bool kexiCompatible=true, bool *cancelled=nullptr, KDbMessageHandler *msgHandler=nullptr)
 
bool useTemporaryDatabaseIfNeeded (QString *name)
 

Public Attributes

 H_INS_REC_ALL
 

Additional Inherited Members

- Protected Types inherited from KDbConnection
enum  AlterTableNameOption { Default = 0, AlterTableNameOption::DropDestination = 1 }
 
typedef QFlags< AlterTableNameOptionAlterTableNameOptions
 
enum  CreateTableOption { Default = 0, CreateTableOption::DropDestination = 1 }
 
typedef QFlags< CreateTableOptionCreateTableOptions
 
enum  QueryRecordOption { QueryRecordOption::AddLimitTo1 = 1, Default = AddLimitTo1 }
 
typedef QFlags< QueryRecordOptionQueryRecordOptions
 
- Protected Member Functions inherited from KDbConnection
 KDbConnection (KDbDriver *driver, const KDbConnectionData &connData, const KDbConnectionOptions &options)
 
void addCursor (KDbCursor *cursor)
 
bool beginAutoCommitTransaction (KDbTransactionGuard *tg)
 
bool checkConnected ()
 
bool checkIfColumnExists (KDbCursor *cursor, int column)
 
bool checkIsDatabaseUsed ()
 
bool commitAutoCommitTransaction (const KDbTransaction &trans)
 
bool deleteAllRecords (KDbQuerySchema *query)
 
bool deleteRecord (KDbQuerySchema *query, KDbRecordData *data, bool useRecordId=false)
 
void destroy ()
 
tristate dropTableInternal (KDbTableSchema *tableSchema, bool alsoRemoveSchema)
 
virtual tristate drv_changeFieldProperty (KDbTableSchema *table, KDbField *field, const QString &propertyName, const QVariant &value)
 
KDbCursorexecuteQueryInternal (const KDbEscapedString &sql, KDbQuerySchema *query, const QList< QVariant > *params)
 
bool insertRecord (KDbQuerySchema *query, KDbRecordData *data, KDbRecordEditBuffer *buf, bool getRecordId=false)
 
QSharedPointer< KDbSqlResultinsertRecordInternal (const QString &tableSchemaName, KDbFieldList *fields, const KDbEscapedString &sql)
 
bool loadExtendedTableSchemaData (KDbTableSchema *tableSchema)
 
tristate querySingleNumberInternal (const KDbEscapedString *sql, int *number, KDbQuerySchema *query, const QList< QVariant > *params, int column, QueryRecordOptions options)
 
tristate querySingleRecordInternal (KDbRecordData *data, const KDbEscapedString *sql, KDbQuerySchema *query, const QList< QVariant > *params, QueryRecordOptions options)
 
tristate querySingleStringInternal (const KDbEscapedString *sql, QString *value, KDbQuerySchema *query, const QList< QVariant > *params, int column, QueryRecordOptions options)
 
bool queryStringListInternal (const KDbEscapedString *sql, QStringList *list, KDbQuerySchema *query, const QList< QVariant > *params, int column, bool(*filterFunction)(const QString &))
 
void removeMe (KDbTableSchema *ts)
 
bool rollbackAutoCommitTransaction (const KDbTransaction &trans)
 
KDbFieldsetupField (const KDbRecordData &data)
 
bool setupObjectData (const KDbRecordData &data, KDbObject *object)
 
bool storeExtendedTableSchemaData (KDbTableSchema *tableSchema)
 
bool storeMainFieldSchema (KDbField *field)
 
void takeCursor (KDbCursor *cursor)
 
bool updateRecord (KDbQuerySchema *query, KDbRecordData *data, KDbRecordEditBuffer *buf, bool useRecordId=false)
 
 ~KDbConnection () override
 
tristate alterTable (KDbTableSchema *tableSchema, KDbTableSchema *newTableSchema)
 
bool alterTableName (KDbTableSchema *tableSchema, const QString &newName, AlterTableNameOptions options=AlterTableNameOption::Default)
 
bool autoCommit () const
 
KDbTransaction beginTransaction ()
 
void clearResult ()
 
bool closeDatabase ()
 
bool commitTransaction (KDbTransaction transaction=KDbTransaction(), KDbTransaction::CommitOptions options=KDbTransaction::CommitOptions())
 
bool connect ()
 
tristate containsTable (const QString &tableName)
 
bool copyDataBlock (int sourceObjectID, int destObjectID, const QString &dataID=QString())
 
KDbTableSchemacopyTable (const KDbTableSchema &tableSchema, const KDbObject &newData)
 
KDbTableSchemacopyTable (const QString &tableName, const KDbObject &newData)
 
bool createDatabase (const QString &dbName)
 
bool createTable (KDbTableSchema *tableSchema, CreateTableOptions options=CreateTableOption::Default)
 
QString currentDatabase () const
 
KDbConnectionData data () const
 
bool databaseExists (const QString &dbName, bool ignoreErrors=true)
 
QStringList databaseNames (bool also_system_db=false)
 
KDbProperties databaseProperties () const
 
KDbVersionInfo databaseVersion () const
 
KDbTransaction defaultTransaction () const
 
bool deleteCursor (KDbCursor *cursor)
 
bool disconnect ()
 
KDbDriverdriver () const
 
bool dropDatabase (const QString &dbName=QString())
 
bool dropQuery (const QString &queryName)
 
bool dropQuery (KDbQuerySchema *querySchema)
 
tristate dropTable (const QString &tableName)
 
tristate dropTable (KDbTableSchema *tableSchema)
 
KDbCursorexecuteQuery (const KDbEscapedString &sql, KDbCursor::Options options=KDbCursor::Option::None)
 
KDbCursorexecuteQuery (KDbQuerySchema *query, const QList< QVariant > &params, KDbCursor::Options options=KDbCursor::Option::None)
 
KDbCursorexecuteQuery (KDbQuerySchema *query, KDbCursor::Options options=KDbCursor::Option::None)
 
KDbCursorexecuteQuery (KDbTableSchema *table, KDbCursor::Options options=KDbCursor::Option::None)
 
bool executeSql (const KDbEscapedString &sql)
 
KDbFieldfindSystemFieldName (const KDbFieldList &fieldlist)
 
QSharedPointer< KDbSqlResultinsertRecord (KDbFieldList *fields, const QList< QVariant > &values)
 
QSharedPointer< KDbSqlResultinsertRecord (KDbTableSchema *tableSchema, const QList< QVariant > &values)
 
bool isConnected () const
 
bool isDatabaseUsed () const
 
tristate isEmpty (KDbTableSchema *table)
 
bool isInternalTableSchema (const QString &tableName)
 
tristate loadDataBlock (int objectID, QString *dataString, const QString &dataID=QString())
 
tristate loadObjectData (int type, const QString &name, KDbObject *object)
 
tristate loadObjectData (int type, int id, KDbObject *object)
 
QList< int > objectIds (int objectType, bool *ok=nullptr)
 
QStringList objectNames (int objectType=KDb::AnyObjectType, bool *ok=nullptr)
 
KDbConnectionOptionsoptions ()
 
KDbCursorprepareQuery (KDbQuerySchema *query, const QList< QVariant > &params, KDbCursor::Options options=KDbCursor::Option::None)
 
KDbCursorprepareQuery (KDbTableSchema *table, KDbCursor::Options options=KDbCursor::Option::None)
 
QSharedPointer< KDbSqlResultprepareSql (const KDbEscapedString &sql)
 
KDbPreparedStatement prepareStatement (KDbPreparedStatement::Type type, KDbFieldList *fields, const QStringList &whereFieldNames=QStringList())
 
QList< int > queryIds (bool *ok=nullptr)
 
KDbQuerySchemaquerySchema (const QString &queryName)
 
KDbQuerySchemaquerySchema (int queryId)
 
tristate querySingleNumber (const KDbEscapedString &sql, int *number, int column=0, QueryRecordOptions options=QueryRecordOption::Default)
 
tristate querySingleNumber (KDbQuerySchema *query, int *number, const QList< QVariant > &params, int column=0, QueryRecordOptions options=QueryRecordOption::Default)
 
tristate querySingleNumber (KDbQuerySchema *query, int *number, int column=0, QueryRecordOptions options=QueryRecordOption::Default)
 
tristate querySingleRecord (const KDbEscapedString &sql, KDbRecordData *data, QueryRecordOptions options=QueryRecordOption::Default)
 
tristate querySingleRecord (KDbQuerySchema *query, KDbRecordData *data, const QList< QVariant > &params, QueryRecordOptions options=QueryRecordOption::Default)
 
tristate querySingleRecord (KDbQuerySchema *query, KDbRecordData *data, QueryRecordOptions options=QueryRecordOption::Default)
 
tristate querySingleString (const KDbEscapedString &sql, QString *value, int column=0, QueryRecordOptions options=QueryRecordOption::Default)
 
tristate querySingleString (KDbQuerySchema *query, QString *value, const QList< QVariant > &params, int column=0, QueryRecordOptions options=QueryRecordOption::Default)
 
tristate querySingleString (KDbQuerySchema *query, QString *value, int column=0, QueryRecordOptions options=QueryRecordOption::Default)
 
bool queryStringList (const KDbEscapedString &sql, QStringList *list, int column=0)
 
bool queryStringList (KDbQuerySchema *query, QStringList *list, const QList< QVariant > &params, int column=0)
 
bool queryStringList (KDbQuerySchema *query, QStringList *list, int column=0)
 
int recordCount (const KDbEscapedString &sql)
 
int recordCount (const KDbTableSchema &tableSchema)
 
int recordCount (KDbQuerySchema *querySchema, const QList< QVariant > &params=QList< QVariant >())
 
int recordCount (KDbTableOrQuerySchema *tableOrQuery, const QList< QVariant > &params=QList< QVariant >())
 
bool removeDataBlock (int objectID, const QString &dataID=QString())
 
bool removeObject (int objId)
 
tristate resultExists (const KDbEscapedString &sql, QueryRecordOptions options=QueryRecordOption::Default)
 
bool rollbackTransaction (KDbTransaction trans=KDbTransaction(), KDbTransaction::CommitOptions options=KDbTransaction::CommitOptions())
 
KDbServerVersionInfo serverVersion () const
 
bool setAutoCommit (bool on)
 
void setAvailableDatabaseName (const QString &dbName)
 
void setDefaultTransaction (const KDbTransaction &trans)
 
bool setQuerySchemaObsolete (const QString &queryName)
 
bool storeDataBlock (int objectID, const QString &dataString, const QString &dataID=QString())
 
bool storeNewObjectData (KDbObject *object)
 
bool storeObjectData (KDbObject *object)
 
QList< int > tableIds (bool *ok=nullptr)
 
QStringList tableNames (bool alsoSystemTables=false, bool *ok=nullptr)
 
KDbTableSchematableSchema (const QString &tableName)
 
KDbTableSchematableSchema (int tableId)
 
QList< KDbTransactiontransactions ()
 
bool useDatabase (const QString &dbName=QString(), bool kexiCompatible=true, bool *cancelled=nullptr, KDbMessageHandler *msgHandler=nullptr)
 
bool useTemporaryDatabaseIfNeeded (QString *name)
 
- Protected Member Functions inherited from KDbResultable
 KDbResultable (const KDbResultable &other)
 
void clearResult ()
 
KDbMessageHandlermessageHandler () const
 
KDbResultableoperator= (const KDbResultable &other)
 
KDbResult result () const
 
virtual QString serverResultName () const
 
void setMessageHandler (KDbMessageHandler *handler)
 
void showMessage ()
 
- Static Protected Member Functions inherited from KDbConnection
static QStringList kdbSystemTableNames ()
 
- Protected Attributes inherited from KDbConnection
 H_INS_REC_ALL
 
- Protected Attributes inherited from KDbResultable
Private *const d
 
KDbResult m_result
 

Detailed Description

The KDbConnectionProxy class gives access to protected (low-level) API of KDbConnection.

The connection object specified in constructor of the proxy is called a parent connection. All inherited methods of the KDbConnection API call equivalent methods of the parent connection. The KDbConnectionProxy class also provides non-virtual methods that are equivalent to KDbConnection ones. These KDbConnection's equivalent methods are called by the proxy too.

Example use of this class is Kexi's database database migration plugins when the source database is only accessibly using low-level routines.

Definition at line 36 of file KDbConnectionProxy.h.

Constructor & Destructor Documentation

◆ KDbConnectionProxy()

KDbConnectionProxy::KDbConnectionProxy ( KDbConnection connection)
explicit

Creates a proxy object for parent connection.

connection must not be nullptr. It is owned by this proxy unless setConnectionIsOwned(false) is called.

Definition at line 44 of file KDbConnectionProxy.cpp.

◆ ~KDbConnectionProxy()

KDbConnectionProxy::~KDbConnectionProxy ( )
override

Deletes this proxy. Owned connection is closed and destroyed.

Definition at line 52 of file KDbConnectionProxy.cpp.

Member Function Documentation

◆ anyAvailableDatabaseName()

QString KDbConnectionProxy::anyAvailableDatabaseName ( )
overridevirtual
Returns
name of any (e.g. first found) database for this connection. This method does not close or open this connection. The method can be used (it is also internally used, e.g. for database dropping) when we need a database name before we can connect and execute any SQL statement (e.g. DROP DATABASE).

The method can return nul lstring, but in this situation no automatic (implicit) connections could be made, what is useful by e.g. dropDatabase().

Note for driver developers: return here a name of database which you are sure is existing. Default implementation returns:

See description of KDbDriverBehavior::ALWAYS_AVAILABLE_DATABASE_NAME member. You may want to reimplement this method only when you need to depend on this connection specifics (e.g. you need to check something remotely).

Reimplemented from KDbConnection.

Definition at line 497 of file KDbConnectionProxy.cpp.

◆ drv_afterInsert()

bool KDbConnectionProxy::drv_afterInsert ( const QString tableName,
KDbFieldList fields 
)
overridevirtual

Postprocessing (if any) required by drivers before execution of an Insert statement. Reimplement this method in your driver if there are any special processing steps to be executed after an Insert statement.

See also
drv_beforeInsert()

Reimplemented from KDbConnection.

Definition at line 712 of file KDbConnectionProxy.cpp.

◆ drv_afterUpdate()

bool KDbConnectionProxy::drv_afterUpdate ( const QString tableName,
KDbFieldList fields 
)
overridevirtual

Postprocessing required by drivers before execution of an Insert statement. Reimplement this method in your driver if there are any special processing steps to be executed after an Update statement.

See also
drv_beforeUpdate()

Reimplemented from KDbConnection.

Definition at line 722 of file KDbConnectionProxy.cpp.

◆ drv_alterTableName()

bool KDbConnectionProxy::drv_alterTableName ( KDbTableSchema tableSchema,
const QString newName 
)
overridevirtual

Alters table's described tableSchema name to newName. This is the default implementation, using "ALTER TABLE <oldname> RENAME TO <newname>", what's supported by SQLite >= 3.2, PostgreSQL, MySQL. Backends lacking ALTER TABLE, for example SQLite, reimplement this with by an inefficient data copying to a new table. In any case, renaming is performed at the backend. It's good idea to keep the operation within a transaction.

Returns
true on success.

Reimplemented from KDbConnection.

Definition at line 610 of file KDbConnectionProxy.cpp.

◆ drv_beforeInsert()

bool KDbConnectionProxy::drv_beforeInsert ( const QString tableName,
KDbFieldList fields 
)
overridevirtual

Preprocessing (if any) required by drivers before execution of an Insert statement. Reimplement this method in your driver if there are any special processing steps to be executed before an Insert statement.

See also
drv_afterInsert()

Reimplemented from KDbConnection.

Definition at line 707 of file KDbConnectionProxy.cpp.

◆ drv_beforeUpdate()

bool KDbConnectionProxy::drv_beforeUpdate ( const QString tableName,
KDbFieldList fields 
)
overridevirtual

Preprocessing required by drivers before execution of an Update statement. Reimplement this method in your driver if there are any special processing steps to be executed before an Update statement.

See also
drv_afterUpdate()

Reimplemented from KDbConnection.

Definition at line 717 of file KDbConnectionProxy.cpp.

◆ drv_beginTransaction()

KDbTransactionData * KDbConnectionProxy::drv_beginTransaction ( )
overridevirtual

Note for driver developers: begins new transaction and returns handle to it. Default implementation just executes "BEGIN" sql statement and returns just empty data (KDbTransactionData object). Ownership of the returned object is passed to the caller.

Drivers that do not support transactions (see KDbDriver::features()) do never call this method. Reimplement this method if you need to do something more (e.g. if you driver will support multiple transactions per connection). Make subclass of KDbTransactionData (declared in KDbTransaction.h) and return object of this subclass. nullptr should be returned on error. Do not check anything in connection (isConnected(), etc.) - all is already done.

Todo:
Add support for nested transactions, e.g. KDbTransactionData* beginTransaction(KDbTransactionData *parent)

Reimplemented from KDbConnection.

Definition at line 692 of file KDbConnectionProxy.cpp.

◆ drv_closeDatabase()

bool KDbConnectionProxy::drv_closeDatabase ( )
overridevirtual

For implementation: closes previously opened database using connection.

Implements KDbConnection.

Definition at line 672 of file KDbConnectionProxy.cpp.

◆ drv_commitTransaction()

bool KDbConnectionProxy::drv_commitTransaction ( KDbTransactionData trans)
overridevirtual

Note for driver developers: begins new transaction and returns handle to it. Default implementation just executes "COMMIT" sql statement and returns true on success.

See also
drv_beginTransaction()

Reimplemented from KDbConnection.

Definition at line 697 of file KDbConnectionProxy.cpp.

◆ drv_connect()

bool KDbConnectionProxy::drv_connect ( )
overridevirtual

For implementation: connects to database.

Returns
true on success.

Implements KDbConnection.

Definition at line 579 of file KDbConnectionProxy.cpp.

◆ drv_containsTable()

tristate KDbConnectionProxy::drv_containsTable ( const QString tableName)
overridevirtual

LOW LEVEL METHOD. For implementation: returns true if table with name tableName exists in the database.

Returns
false if it does not exist or cancelled if error occurred. The lookup is case insensitive.

Implements KDbConnection.

Definition at line 600 of file KDbConnectionProxy.cpp.

◆ drv_copyTableData()

bool KDbConnectionProxy::drv_copyTableData ( const KDbTableSchema tableSchema,
const KDbTableSchema destinationTableSchema 
)
overridevirtual

Copies table data from tableSchema to destinationTableSchema Default implementation executes "INSERT INTO .. SELECT * FROM .."

Returns
true on success.

Reimplemented from KDbConnection.

Definition at line 615 of file KDbConnectionProxy.cpp.

◆ drv_createDatabase()

bool KDbConnectionProxy::drv_createDatabase ( const QString dbName = QString())
overridevirtual

For implementation: creates new database using connection

Implements KDbConnection.

Definition at line 661 of file KDbConnectionProxy.cpp.

◆ drv_createTable() [1/2]

bool KDbConnectionProxy::drv_createTable ( const KDbTableSchema tableSchema)
overridevirtual

Creates table using tableSchema information.

Returns
true on success.

Default implementation builds a statement using createTableStatement() and calls executeSql(). Note for driver developers: reimplement this only to perform creation in other way.

Reimplemented from KDbConnection.

Definition at line 605 of file KDbConnectionProxy.cpp.

◆ drv_createTable() [2/2]

bool KDbConnectionProxy::drv_createTable ( const QString tableName)
overridevirtual

Creates table named by tableName. Schema object must be on schema tables' list before calling this method (otherwise false if returned). Just uses drv_createTable( const KDbTableSchema& tableSchema ). Used internally, e.g. in createDatabase().

Returns
true on success

Reimplemented from KDbConnection.

Definition at line 687 of file KDbConnectionProxy.cpp.

◆ drv_databaseExists()

bool KDbConnectionProxy::drv_databaseExists ( const QString dbName,
bool  ignoreErrors = true 
)
overridevirtual

For optional reimplementation: asks server if database dbName exists. This method is used internally in databaseExists(). The default implementation calls databaseNames and checks if that list contains dbName. If you need to ask the server specifically if a database exists, eg. if you can't retrieve a list of all available database names, please reimplement this method and do all needed checks.

See databaseExists() description for details about ignoreErrors argument. You should use it properly in your implementation.

Note: This method should also work if there is already database used (with useDatabase()); in this situation no changes should be made in current database selection.

Reimplemented from KDbConnection.

Definition at line 656 of file KDbConnectionProxy.cpp.

◆ drv_disconnect()

bool KDbConnectionProxy::drv_disconnect ( )
overridevirtual

For implementation: disconnects database

Returns
true on success.

Implements KDbConnection.

Definition at line 584 of file KDbConnectionProxy.cpp.

◆ drv_dropDatabase()

bool KDbConnectionProxy::drv_dropDatabase ( const QString dbName = QString())
overridevirtual

For implementation: drops database from the server using connection. After drop, database shouldn't be accessible anymore.

Implements KDbConnection.

Definition at line 682 of file KDbConnectionProxy.cpp.

◆ drv_dropTable()

bool KDbConnectionProxy::drv_dropTable ( const QString tableName)
overridevirtual

Physically drops table named with name. Default impelmentation executes "DROP TABLE.." command, so you rarely want to change this.

Reimplemented from KDbConnection.

Definition at line 621 of file KDbConnectionProxy.cpp.

◆ drv_executeSql()

bool KDbConnectionProxy::drv_executeSql ( const KDbEscapedString sql)
overridevirtual

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 646 of file KDbConnectionProxy.cpp.

◆ drv_getDatabasesList()

bool KDbConnectionProxy::drv_getDatabasesList ( QStringList list)
overridevirtual

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 651 of file KDbConnectionProxy.cpp.

◆ drv_getServerVersion()

bool KDbConnectionProxy::drv_getServerVersion ( KDbServerVersionInfo version)
overridevirtual

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.

Implements KDbConnection.

Definition at line 589 of file KDbConnectionProxy.cpp.

◆ drv_getTableNames()

QStringList KDbConnectionProxy::drv_getTableNames ( bool *  ok)
overridevirtual
Since
3.2

Reimplemented from KDbConnection.

Definition at line 594 of file KDbConnectionProxy.cpp.

◆ drv_isDatabaseUsed()

bool KDbConnectionProxy::drv_isDatabaseUsed ( ) const
overridevirtual
Returns
true if internal driver's structure is still in opened/connected state and database is used. Note for driver developers: Put here every test that you can do using your internal engine's database API, eg (a bit schematic): my_connection_struct->isConnected()==true. Do not check things like KDbConnection::isDatabaseUsed() here or other things that "KDb already knows" at its level. If you cannot test anything, just leave default implementation (that returns true).

Result of this method is used as an additional chance to check for isDatabaseUsed(). Do not call this method from your driver's code, it should be used at KDb level only.

Reimplemented from KDbConnection.

Definition at line 677 of file KDbConnectionProxy.cpp.

◆ drv_prepareSql()

KDbSqlResult * KDbConnectionProxy::drv_prepareSql ( const KDbEscapedString sql)
overridevirtual

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

Implements KDbConnection.

Definition at line 641 of file KDbConnectionProxy.cpp.

◆ drv_rollbackTransaction()

bool KDbConnectionProxy::drv_rollbackTransaction ( KDbTransactionData trans)
overridevirtual

Note for driver developers: begins new transaction and returns handle to it. Default implementation just executes "ROLLBACK" sql statement and returns true on success.

See also
drv_beginTransaction()

Reimplemented from KDbConnection.

Definition at line 702 of file KDbConnectionProxy.cpp.

◆ drv_setAutoCommit()

bool KDbConnectionProxy::drv_setAutoCommit ( bool  on)
overridevirtual

Changes autocommiting option for established connection.

Returns
true on success.

Note for driver developers: reimplement this only if your engine allows to set special auto commit option (like "SET AUTOCOMMIT=.." in MySQL). If not, auto commit behavior will be simulated if at least single transactions per connection are supported by the engine. Do not set any internal flags for autocommiting – it is already done inside setAutoCommit().

Default implementation does nothing with connection, just returns true.

See also
drv_beginTransaction(), autoCommit(), setAutoCommit()

Reimplemented from KDbConnection.

Definition at line 727 of file KDbConnectionProxy.cpp.

◆ drv_useDatabase()

bool KDbConnectionProxy::drv_useDatabase ( const QString dbName = QString(),
bool *  cancelled = nullptr,
KDbMessageHandler msgHandler = nullptr 
)
overridevirtual

For implementation: opens existing database using connection

Returns
true on success, false on failure; sets cancelled to true if this action has been cancelled.

Implements KDbConnection.

Definition at line 666 of file KDbConnectionProxy.cpp.

◆ escapeIdentifier()

QString KDbConnectionProxy::escapeIdentifier ( const QString id) const
overridevirtual

Identifier escaping function in the associated KDbDriver.

Calls the identifier escaping function in this connection to escape table and column names. This should be used when explicitly constructing SQL strings (e.g. "FROM " + escapeIdentifier(tablename)). It should not be used for other functions (e.g. don't do useDatabase(escapeIdentifier(database))), because the identifier will be escaped when the called function generates, for example, "USE " + escapeIdentifier(database).

For efficiency, KDb "system" tables (prefixed with kexi__) and columns therein are not escaped - we assume these are valid identifiers for all drivers.

Use KDbEscapedString::isValid() to check if escaping has been performed successfully. Invalid strings are set to null in addition, that is KDbEscapedString::isNull() is true, not just isEmpty().

Reimplemented from KDbConnection.

Definition at line 574 of file KDbConnectionProxy.cpp.

◆ escapeString()

KDbEscapedString KDbConnectionProxy::escapeString ( const QString str) const
overridevirtual

Connection-specific string escaping. Default implementation uses driver's escaping. Use KDbEscapedString::isValid() to check if escaping has been performed successfully. Invalid strings are set to null in addition, that is KDbEscapedString::isNull() is true, not just isEmpty().

Reimplemented from KDbConnection.

Definition at line 245 of file KDbConnectionProxy.cpp.

◆ loadObjectData()

tristate KDbConnectionProxy::loadObjectData ( int  type,
int  id,
KDbObject object 
)
Since
3.1

Definition at line 532 of file KDbConnectionProxy.cpp.

◆ parentConnection()

KDbConnection * KDbConnectionProxy::parentConnection ( )
Returns
parent connection for this proxy

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 57 of file KDbConnectionProxy.cpp.

◆ prepareQuery() [1/2]

KDbCursor * KDbConnectionProxy::prepareQuery ( const KDbEscapedString sql,
KDbCursor::Options  options = KDbCursor::Option::None 
)
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 250 of file KDbConnectionProxy.cpp.

◆ prepareQuery() [2/2]

KDbCursor * KDbConnectionProxy::prepareQuery ( KDbQuerySchema query,
KDbCursor::Options  options = KDbCursor::Option::None 
)
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 255 of file KDbConnectionProxy.cpp.

◆ prepareStatementInternal()

KDbPreparedStatementInterface * KDbConnectionProxy::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 732 of file KDbConnectionProxy.cpp.

◆ recentSqlString()

KDbEscapedString KDbConnectionProxy::recentSqlString ( ) const
overridevirtual

Return recently used SQL string.

If there was a successful query execution it is equal to result().sql(), otherwise it is equal to result().errorSql().

Reimplemented from KDbConnection.

Definition at line 398 of file KDbConnectionProxy.cpp.

◆ setParentConnectionIsOwned()

void KDbConnectionProxy::setParentConnectionIsOwned ( bool  set)

Control owhership of parent connection that is assigned to this proxy.

Owned connection is closed and destroyed upon destruction of the KDbConnectionProxy object.

Definition at line 67 of file KDbConnectionProxy.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Thu Feb 15 2024 04:08:26 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.