kexi

KexiDB::Connection Class Reference

#include <connection.h>

Inheritance diagram for KexiDB::Connection:

KexiDB::Object KexiDB::MySqlConnection KexiDB::pqxxSqlConnection KexiDB::SQLiteConnection List of all members.

Detailed Description

Provides database connection, allowing queries and data modification.

This class represents a database connection established within a data source. It supports data queries and modification by creating client-side database cursors. Database transactions are supported.

Definition at line 61 of file connection.h.


Public Member Functions

virtual ~Connection ()
ConnectionDatadata () const
Driverdriver () const
bool connect ()
bool isConnected () const
bool isDatabaseUsed () const
virtual bool isReadOnly () const
virtual void clearError ()
bool disconnect ()
QStringList databaseNames (bool also_system_db=false)
bool databaseExists (const QString &dbName, bool ignoreErrors=true)
bool createDatabase (const QString &dbName)
bool useDatabase (const QString &dbName, bool kexiCompatible=true, bool *cancelled=0, MessageHandler *msgHandler=0)
bool closeDatabase ()
QString currentDatabase () const
bool dropDatabase (const QString &dbName=QString::null)
QStringList objectNames (int objType=KexiDB::AnyObjectType, bool *ok=0)
QStringList tableNames (bool also_system_tables=false)
KexiDB::ServerVersionInfoserverVersion () const
KexiDB::DatabaseVersionInfodatabaseVersion () const
DatabasePropertiesdatabaseProperties ()
QValueList< int > tableIds ()
QValueList< int > queryIds ()
QValueList< int > objectIds (int objType)
Transaction beginTransaction ()
bool commitTransaction (Transaction trans=Transaction::null, bool ignore_inactive=false)
bool rollbackTransaction (Transaction trans=Transaction::null, bool ignore_inactive=false)
TransactiondefaultTransaction () const
void setDefaultTransaction (const Transaction &trans)
const QValueList< Transaction > & transactions ()
bool autoCommit () const
bool setAutoCommit (bool on)
virtual CursorprepareQuery (const QString &statement, uint cursor_options=0)=0
CursorprepareQuery (QuerySchema &query, const QValueList< QVariant > &params, uint cursor_options=0)
virtual CursorprepareQuery (QuerySchema &query, uint cursor_options=0)=0
CursorprepareQuery (TableSchema &table, uint cursor_options=0)
CursorexecuteQuery (const QString &statement, uint cursor_options=0)
CursorexecuteQuery (QuerySchema &query, const QValueList< QVariant > &params, uint cursor_options=0)
CursorexecuteQuery (QuerySchema &query, uint cursor_options=0)
CursorexecuteQuery (TableSchema &table, uint cursor_options=0)
bool deleteCursor (Cursor *cursor)
TableSchematableSchema (int tableId)
TableSchematableSchema (const QString &tableName)
QuerySchemaquerySchema (int queryId)
QuerySchemaquerySchema (const QString &queryName)
bool setQuerySchemaObsolete (const QString &queryName)
tristate querySingleRecord (const QString &sql, RowData &data, bool addLimitTo1=true)
tristate querySingleRecord (QuerySchema &query, RowData &data, bool addLimitTo1=true)
tristate querySingleString (const QString &sql, QString &value, uint column=0, bool addLimitTo1=true)
tristate querySingleNumber (const QString &sql, int &number, uint column=0, bool addLimitTo1=true)
bool queryStringList (const QString &sql, QStringList &list, uint column=0)
bool resultExists (const QString &sql, bool &success, bool addLimitTo1=true)
bool isEmpty (TableSchema &table, bool &success)
int resultCount (const QString &sql)
bool insertRecord (TableSchema &tableSchema, QValueList< QVariant > &values)
bool insertRecord (FieldList &fields, QValueList< QVariant > &values)
bool createTable (TableSchema *tableSchema, bool replaceExisting=false)
tristate dropTable (TableSchema *tableSchema)
tristate dropTable (const QString &table)
tristate alterTable (TableSchema &tableSchema, TableSchema &newTableSchema)
bool alterTableName (TableSchema &tableSchema, const QString &newName, bool replace=false)
bool dropQuery (QuerySchema *querySchema)
bool dropQuery (const QString &query)
bool removeObject (uint objId)
FieldfindSystemFieldName (FieldList *fieldlist)
virtual QString anyAvailableDatabaseName ()
void setAvailableDatabaseName (const QString &dbName)
bool useTemporaryDatabaseIfNeeded (QString &tmpdbName)
Q_ULLONG lastInsertedAutoIncValue (const QString &aiFieldName, const QString &tableName, Q_ULLONG *ROWID=0)
Q_ULLONG lastInsertedAutoIncValue (const QString &aiFieldName, const TableSchema &table, Q_ULLONG *ROWID=0)
bool executeSQL (const QString &statement)
QString selectStatement (QuerySchema &querySchema, const QValueList< QVariant > &params, const SelectStatementOptions &options=SelectStatementOptions()) const
QString selectStatement (QuerySchema &querySchema, const SelectStatementOptions &options=SelectStatementOptions()) const
bool storeObjectSchemaData (SchemaData &sdata, bool newObject)
tristate loadObjectSchemaData (int objectID, SchemaData &sdata)
tristate loadObjectSchemaData (int objectType, const QString &objectName, SchemaData &sdata)
tristate loadDataBlock (int objectID, QString &dataString, const QString &dataID)
bool storeDataBlock (int objectID, const QString &dataString, const QString &dataID=QString::null)
bool removeDataBlock (int objectID, const QString &dataID=QString::null)
void registerForTableSchemaChanges (TableSchemaChangeListenerInterface &listener, TableSchema &schema)
void unregisterForTableSchemaChanges (TableSchemaChangeListenerInterface &listener, TableSchema &schema)
void unregisterForTablesSchemaChanges (TableSchemaChangeListenerInterface &listener)
QPtrList< Connection::TableSchemaChangeListenerInterface > * tableSchemaChangeListeners (TableSchema &tableSchema) const
tristate closeAllTableSchemaChangeListeners (TableSchema &tableSchema)
void removeTableSchemaInternal (KexiDB::TableSchema *tableSchema)
void insertInternalTableSchema (TableSchema *tableSchema)
virtual bool drv_containsTable (const QString &tableName)=0
virtual bool drv_createTable (const TableSchema &tableSchema)
virtual bool drv_alterTableName (TableSchema &tableSchema, const QString &newName)
virtual bool drv_dropTable (const QString &name)
virtual PreparedStatement::Ptr prepareStatement (PreparedStatement::StatementType type, FieldList &fields)=0
bool isInternalTableSchema (const QString &tableName)
bool setupObjectSchemaData (const RowData &data, SchemaData &sdata)
KexiDB::FieldsetupField (const RowData &data)

Static Public Member Functions

static const QStringList & kexiDBSystemTableNames ()

Public Attributes

 H_INS_REC_ALL

Protected Member Functions

 Connection (Driver *driver, ConnectionData &conn_data)
void destroy ()
tristate dropTable (KexiDB::TableSchema *tableSchema, bool alsoRemoveSchema)
virtual bool drv_connect (KexiDB::ServerVersionInfo &version)=0
virtual bool drv_disconnect ()=0
virtual bool drv_executeSQL (const QString &statement)=0
virtual bool drv_getDatabasesList (QStringList &list)
virtual bool drv_getTablesList (QStringList &list)=0
virtual bool drv_databaseExists (const QString &dbName, bool ignoreErrors=true)
virtual bool drv_createDatabase (const QString &dbName=QString::null)=0
virtual bool drv_useDatabase (const QString &dbName=QString::null, bool *cancelled=0, MessageHandler *msgHandler=0)=0
virtual bool drv_closeDatabase ()=0
virtual bool drv_isDatabaseUsed () const
virtual bool drv_dropDatabase (const QString &dbName=QString::null)=0
QString createTableStatement (const TableSchema &tableSchema) const
QString selectStatement (TableSchema &tableSchema, const SelectStatementOptions &options=SelectStatementOptions()) const
virtual bool drv_createTable (const QString &tableSchemaName)
virtual Q_ULLONG drv_lastInsertRowID ()=0
virtual TransactionDatadrv_beginTransaction ()
virtual bool drv_commitTransaction (TransactionData *trans)
virtual bool drv_rollbackTransaction (TransactionData *trans)
virtual bool drv_setAutoCommit (bool on)
bool beginAutoCommitTransaction (TransactionGuard &tg)
bool commitAutoCommitTransaction (const Transaction &trans)
bool rollbackAutoCommitTransaction (const Transaction &trans)
bool checkConnected ()
bool checkIsDatabaseUsed ()
TableSchemasetupTableSchema (const RowData &data)
QuerySchemasetupQuerySchema (const RowData &data)
bool updateRow (QuerySchema &query, RowData &data, RowEditBuffer &buf, bool useROWID=false)
bool insertRow (QuerySchema &query, RowData &data, RowEditBuffer &buf, bool getROWID=false)
bool deleteRow (QuerySchema &query, RowData &data, bool useROWID=false)
bool deleteAllRows (QuerySchema &query)
bool setupKexiDBSystemSchema ()
TableSchemanewKexiDBSystemTableSchema (const QString &tsname)
QString escapeIdentifier (const QString &id, int escaping=Driver::EscapeDriver|Driver::EscapeAsNecessary) const
void removeMe (TableSchema *ts)
bool checkIfColumnExists (Cursor *cursor, uint column)
tristate querySingleRecordInternal (RowData &data, const QString *sql, QuerySchema *query, bool addLimitTo1=true)
void setReadOnly (bool set)
bool loadExtendedTableSchemaData (TableSchema &tableSchema)
bool storeExtendedTableSchemaData (TableSchema &tableSchema)
bool storeMainFieldSchema (Field *field)
virtual tristate drv_changeFieldProperty (TableSchema &table, Field &field, const QString &propertyName, const QVariant &value)

Protected Attributes

QPtrDict< KexiDB::Cursorm_cursors

Friends

class KexiDB::Driver
class KexiDB::Cursor
class KexiDB::TableSchema
class KexiDB::DatabaseProperties
class ConnectionPrivate
class KexiDB::AlterTableHandler

Classes

class  SelectStatementOptions
 options used in selectStatement() More...
class  TableSchemaChangeListenerInterface

Constructor & Destructor Documentation

Connection::~Connection (  )  [virtual]

Opened connection is automatically disconnected and removed from driver's connections list. Note for driver developers: you should call destroy() from you Connection's subclass destructor.

Definition at line 221 of file connection.cpp.

Connection::Connection ( Driver driver,
ConnectionData conn_data 
) [protected]

Used by Driver

Definition at line 198 of file connection.cpp.


Member Function Documentation

ConnectionData * Connection::data (  )  const

Returns:
parameters that were used to create this connection.

Definition at line 240 of file connection.cpp.

Driver* KexiDB::Connection::driver (  )  const [inline]

Returns:
the driver used for this connection.

Definition at line 77 of file connection.h.

bool Connection::connect (  ) 

Connects to driver with given parameters.

Returns:
true if successful.

Definition at line 245 of file connection.cpp.

bool Connection::isConnected (  )  const

Returns:
true, if connection is properly established.

Definition at line 288 of file connection.cpp.

bool Connection::isDatabaseUsed (  )  const

Returns:
true, both if connection is properly established and any database within this connection is properly used with useDatabase().

Definition at line 262 of file connection.cpp.

bool Connection::isReadOnly (  )  const [virtual]

Returns:
true for read only connection. Used especially for file-based drivers. Can be reimplemented in a driver to provide real read-only flag of the connection (SQlite3 dirver does this).

Reimplemented in KexiDB::SQLiteConnection.

Definition at line 3545 of file connection.cpp.

void Connection::clearError (  )  [virtual]

Reimplemented from Object: also clears sql string.

See also:
recentSQLString()

Reimplemented from KexiDB::Object.

Definition at line 267 of file connection.cpp.

bool Connection::disconnect (  ) 

Disconnects from driver with given parameters.

The database (if used) is closed, and any active transactions (if supported) are rolled back, so commit these before disconnecting, if you'd like to save your changes.

Definition at line 273 of file connection.cpp.

QStringList Connection::databaseNames ( bool  also_system_db = false  ) 

Returns:
list of database names for opened connection. If also_system_db is true, the system database names are also returned.

Definition at line 313 of file connection.cpp.

bool Connection::databaseExists ( const QString &  dbName,
bool  ignoreErrors = true 
)

Returns:
true if database dbName exists. If ignoreErrors is true, error flag of connection won't be modified for any errors (it will quietly return), else (ignoreErrors == false) we can check why the database does not exist using error(), errorNum() and/or errorMsg().

Definition at line 372 of file connection.cpp.

bool Connection::createDatabase ( const QString &  dbName  ) 

Creates new database with name dbName, using this connection.

If database with dbName already exists, or other error occurred, false is returned. For file-based drivers, dbName should be equal to the database filename (the same as specified for ConnectionData).

See doc/dev/kexidb_issues.txt document, chapter "Table schema, query schema, etc. storage" for database schema documentation (detailed description of kexi__* 'system' tables).

See also:
useDatabase()

Definition at line 434 of file connection.cpp.

bool Connection::useDatabase ( const QString &  dbName,
bool  kexiCompatible = true,
bool *  cancelled = 0,
MessageHandler msgHandler = 0 
)

Opens an existing database specified by dbName.

If kexiCompatible is true (the default) initial checks will be performed to recognize database Kexi-specific format. Set kexiCompatible to false if you're using native database (one that have no Kexi System tables). For file-based drivers, dbName should be equal to filename (the same as specified for ConnectionData).

Returns:
true on success, false on failure. If user has cancelled this action and cancelled is not 0, *cancelled is set to true.

Definition at line 536 of file connection.cpp.

bool Connection::closeDatabase (  ) 

Closes currently used database for this connection.

Any active transactions (if supported) are rolled back, so commit these before closing, if you'd like to save your changes.

Todo:
(js) add CLEVER algorithm here for nested transactions

Definition at line 623 of file connection.cpp.

QString Connection::currentDatabase (  )  const

Get the name of the current database.

Returns:
name of currently used database for this connection or empty string if there is no used database

Definition at line 666 of file connection.cpp.

bool Connection::dropDatabase ( const QString &  dbName = QString::null  ) 

Drops database with name dbName.

if dbName is not specified, currently used database name is used (it is closed before dropping).

Definition at line 695 of file connection.cpp.

QStringList Connection::objectNames ( int  objType = KexiDB::AnyObjectType,
bool *  ok = 0 
)

Returns:
names of all the objecttype (see ObjectTypes in global.h) schemas stored in currently used database. KexiDB::AnyObjectType can be passed as objType to get names of objects of any type. If ok is not null then variable pointed by it will be set to the result. On error, the functions can return incomplete list.

Definition at line 753 of file connection.cpp.

QStringList Connection::tableNames ( bool  also_system_tables = false  ) 

Returns:
names of all table schemas stored in currently used database. If also_system_tables is true, internal KexiDB system table names (kexi__*) are also returned.
See also:
kexiDBSystemTableNames()

Definition at line 794 of file connection.cpp.

const QStringList & Connection::kexiDBSystemTableNames (  )  [static]

Returns:
list of internal KexiDB system table names (kexi__*). This does not mean that these tables can be found in currently opened database. Just static list of table names is returned.
The list contents may depend on KexiDB library version; opened database can contain fewer 'system' tables than in current KexiDB implementation, if the current one is newer than the one used to build the database.

Definition at line 805 of file connection.cpp.

KexiDB::ServerVersionInfo * Connection::serverVersion (  )  const

Returns:
server version information for this connection. If database is not connected (i.e. isConnected() is false) 0 is returned.

Definition at line 821 of file connection.cpp.

KexiDB::DatabaseVersionInfo * Connection::databaseVersion (  )  const

Returns:
version information for this connection. If database is not used (i.e. isDatabaseUsed() is false) 0 is returned. It can be compared to drivers' and KexiDB library version to maintain backward/upward compatiblility.

Definition at line 826 of file connection.cpp.

DatabaseProperties & Connection::databaseProperties (  ) 

Returns:
DatabaseProperties object allowing to read and write global database properties for this connection.

Definition at line 831 of file connection.cpp.

QValueList< int > Connection::tableIds (  ) 

Returns:
ids of all table schema names stored in currently used database. These ids can be later used as argument for tableSchema(). This is a shortcut for objectIds(TableObjectType). If also_system_tables is true, Internal KexiDB system tables (kexi__*) are not available here because these have no identifiers assigned (more formally: id=-1).

Definition at line 836 of file connection.cpp.

QValueList< int > Connection::queryIds (  ) 

Returns:
ids of all database query schemas stored in currently used database. These ids can be later used as argument for querySchema(). This is a shortcut for objectIds(TableObjectType).

Definition at line 841 of file connection.cpp.

QValueList< int > Connection::objectIds ( int  objType  ) 

Returns:
names of all schemas of object with objType type that are stored in currently used database.

Definition at line 846 of file connection.cpp.

Transaction Connection::beginTransaction (  ) 

Creates new transaction handle and starts a new transaction.

Returns:
KexiDB::Transaction object if transaction has been started successfully, otherwise null transaction. For drivers that allow single transaction per connection (Driver::features() && SingleTransactions) this method can be called one time, and then this single transaction will be default ( setDefaultTransaction() will be called). For drivers that allow multiple transactions per connection, no default transaction is set automatically in beginTransaction() method, you could do this by hand.
See also:
setDefaultTransaction(), defaultTransaction().

Definition at line 2021 of file connection.cpp.

bool Connection::commitTransaction ( Transaction  trans = Transaction::null,
bool  ignore_inactive = false 
)

Commits transaction trans. If there is not trans argument passed, and there is default transaction (obtained from defaultTransaction()) defined, this one will be committed. If default is not present, false is returned (when ignore_inactive is false, the default), or true is returned (when ignore_inactive is true).

On successful commit, trans object will be destroyed. If this was default transaction, there is no default transaction for now.

Definition at line 2059 of file connection.cpp.

bool Connection::rollbackTransaction ( Transaction  trans = Transaction::null,
bool  ignore_inactive = false 
)

Rollbacks transaction trans. If there is not trans argument passed, and there is default transaction (obtained from defaultTransaction()) defined, this one will be rolled back. If default is not present, false is returned (when ignore_inactive is false, the default), or true is returned (when ignore_inactive is true).

or any error occurred, false is returned.

On successful rollback, trans object will be destroyed. If this was default transaction, there is no default transaction for now.

Definition at line 2095 of file connection.cpp.

Transaction & Connection::defaultTransaction (  )  const

Returns:
handle for default transaction for this connection or null transaction if there is no such a transaction defined. If transactions are supported: Any operation on database (e.g. inserts) that is started without specifying transaction context, will be performed in the context of this transaction.
Returned null transaction doesn't mean that there is no transactions started at all. Default transaction can be defined automatically for some drivers -- see beginTransaction().
See also:
KexiDB::Driver::transactionsSupported()

Definition at line 2139 of file connection.cpp.

void Connection::setDefaultTransaction ( const Transaction trans  ) 

Sets default transaction that will be used as context for operations on data in opened database for this connection.

Definition at line 2144 of file connection.cpp.

const QValueList< Transaction > & Connection::transactions (  ) 

Returns:
set of handles of currently active transactions. Note that in multithreading environment some of these transactions can be already inactive after calling this method. Use Transaction::active() to check that. Inactive transaction handle is useless and can be safely dropped.

Definition at line 2158 of file connection.cpp.

bool Connection::autoCommit (  )  const

Returns:
true if "auto commit" option is on.
When auto commit is on (the default on for any new Connection object), every sql functional statement (statement that changes data in the database implicitly starts a new transaction. This transaction is automatically committed after successful statement execution or rolled back on error.

For drivers that do not support transactions (see Driver::features()) this method shouldn't be called because it does nothing ans always returns false.

No internal KexiDB object should changes this option, although auto commit's behaviour depends on database engine's specifics. Engines that support only single transaction per connection (see Driver::SingleTransactions), use this single connection for autocommiting, so if there is already transaction started by the KexiDB user program (with beginTransaction()), this transaction is committed before any sql functional statement execution. In this situation default transaction is also affected (see defaultTransaction()).

Only for drivers that support nested transactions (Driver::NestedTransactions), autocommiting works independently from previously started transaction,

For other drivers set this option off if you need use transaction for grouping more statements together.

NOTE: nested transactions are not yet implemented in KexiDB API.

Definition at line 2163 of file connection.cpp.

bool Connection::setAutoCommit ( bool  on  ) 

Changes auto commit option. This does not affect currently started transactions. This option can be changed even when connection is not established.

See also:
autoCommit()

Definition at line 2168 of file connection.cpp.

KexiDB::Connection::prepareQuery ( const QString &  statement = QString::null,
uint  cursor_options = 0 
) [pure virtual]

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

Statement is build from data provided by table schema, it is like "select * from table_name".

Implemented in KexiDB::MySqlConnection, KexiDB::pqxxSqlConnection, and KexiDB::SQLiteConnection.

KexiDB::Connection::executeQuery ( const QString &  statement,
uint  cursor_options = 0 
)

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

Executes query described by query schema without parameters. Statement is build from data provided by table schema, it is like "select * from table_name".

Definition at line 2201 of file connection.cpp.

bool Connection::deleteCursor ( Cursor cursor  ) 

Deletes cursor cursor previously created by functions like executeQuery() for this connection. There is an attempt to close the cursor with Cursor::close() if it was opened. Anyway, at last cursor is deleted.

Returns:
true if cursor is properly closed before deletion.

Definition at line 2254 of file connection.cpp.

TableSchema * Connection::tableSchema ( int  tableId  ) 

Returns:
schema of a table pointed by tableId, retrieved from currently used database. The schema is cached inside connection, so retrieval is performed only once, on demand.

Definition at line 2876 of file connection.cpp.

TableSchema * Connection::tableSchema ( const QString &  tableName  ) 

Returns:
schema of a table pointed by tableName, retrieved from currently used database. KexiDB system table schema can be also retrieved.
See also:
tableSchema( int tableId )

Definition at line 2860 of file connection.cpp.

QuerySchema * Connection::querySchema ( int  queryId  ) 

Returns:
schema of a query pointed by queryId, retrieved from currently used database. The schema is cached inside connection, so retrieval is performed only once, on demand.

Definition at line 2983 of file connection.cpp.

QuerySchema * Connection::querySchema ( const QString &  queryName  ) 

Returns:
schema of a query pointed by queryName, retrieved from currently used database.
See also:
querySchema( int queryId )

Definition at line 2967 of file connection.cpp.

bool Connection::setQuerySchemaObsolete ( const QString &  queryName  ) 

Sets queryName query obsolete by moving it out of the query sets, so it will not be accessible by querySchema( const QString& queryName ). The existing query object is not destroyed, to avoid problems when it's referenced. In this case, a new query schema will be retrieved directly from the backend.

For now it's used in KexiQueryDesignerGuiEditor::storeLayout(). This solves the problem when user has changed a query schema but already form still uses previously instantiated query schema.

Returns:
true if there is such query. Otherwise the method does nothing.

Definition at line 2998 of file connection.cpp.

tristate Connection::querySingleRecord ( const QString &  sql,
RowData data,
bool  addLimitTo1 = true 
)

Executes sql query and stores first record's data inside data. This is convenient method when we need only first record from query result, or when we know that query result has only one record. If addLimitTo1 is true (the default), adds a LIMIT clause to the query, so sql should not include one already.

Returns:
true if query was successfully executed and first record has been found, false on data retrieving failure, and cancelled if there's no single record available.

Definition at line 2395 of file connection.cpp.

tristate Connection::querySingleRecord ( QuerySchema query,
RowData data,
bool  addLimitTo1 = true 
)

Like tristate querySingleRecord(const QString& sql, RowData &data) but uses QuerySchema object. If addLimitTo1 is true (the default), adds a LIMIT clause to the query.

Definition at line 2400 of file connection.cpp.

tristate Connection::querySingleString ( const QString &  sql,
QString &  value,
uint  column = 0,
bool  addLimitTo1 = true 
)

Executes sql query and stores first record's field's (number column) string value inside value. For efficiency it's recommended that a query defined by sql should have just one field (SELECT one_field FROM ....). If addLimitTo1 is true (the default), adds a LIMIT clause to the query, so sql should not include one already.

Returns:
true if query was successfully executed and first record has been found, false on data retrieving failure, and cancelled if there's no single record available.
See also:
queryStringList()

Definition at line 2414 of file connection.cpp.

tristate Connection::querySingleNumber ( const QString &  sql,
int &  number,
uint  column = 0,
bool  addLimitTo1 = true 
)

Convenience function: executes sql query and stores first record's field's (number column) value inside number.

See also:
querySingleString(). Note: "LIMIT 1" is appended to sql statement if addLimitTo1 is true (the default).
Returns:
true if query was successfully executed and first record has been found, false on data retrieving failure, and cancelled if there's no single record available.

Definition at line 2436 of file connection.cpp.

bool Connection::queryStringList ( const QString &  sql,
QStringList &  list,
uint  column = 0 
)

Executes sql query and stores Nth field's string value of every record inside list, where N is equal to column. The list is initially cleared. For efficiency it's recommended that a query defined by sql should have just one field (SELECT one_field FROM ....).

Returns:
true if all values were fetched successfuly, false on data retrieving failure. Returning empty list can be still a valid result. On errors, the list is not cleared, it may contain a few retrieved values.

Definition at line 2447 of file connection.cpp.

bool Connection::resultExists ( const QString &  sql,
bool &  success,
bool  addLimitTo1 = true 
)

Returns:
true if there is at least one record returned in sql query. Does not fetch any records. success will be set to false on query execution errors (true otherwise), so you can see a difference between "no results" and "query execution error" states. Note: real executed query is: "SELECT 1 FROM (\a sql) LIMIT 1" if addLimitTo1 is true (the default).

Definition at line 2478 of file connection.cpp.

bool Connection::isEmpty ( TableSchema table,
bool &  success 
)

Returns:
true if there is at least one record in table.

Definition at line 2511 of file connection.cpp.

int KexiDB::Connection::resultCount ( const QString &  sql  ) 

Returns:
number of records in sql query. Does not fetch any records. -1 is returned on query execution errors (>0 otherwise). Note: real executed query is: "SELECT COUNT() FROM (\a sql) LIMIT 1" (using querySingleNumber())

bool Connection::createTable ( TableSchema tableSchema,
bool  replaceExisting = false 
)

Creates a table according to the given schema.

Creates table defined by tableSchema. Schema information is also added into kexi system tables, for later reuse.

Returns:
true on success - tableSchema object is then inserted to Connection structures - it is owned by Connection object now, so you shouldn't destroy the tableSchema object by hand (or declare it as local-scope variable).
If replaceExisting is false (the default) and table with the same name (as tableSchema->name()) exists, false is returned. If replaceExisting is true, a table schema with the same name (if exists) is overwritten, then a new table schema gets the same identifier as existing table schema's identifier.

Note that on error:

  • tableSchema is not inserted into Connection's structures, so you are still owner of this object
  • existing table schema object is not destroyed (i.e. it is still available e.g. using Connection::tableSchema(const QString& ), even if the table was physically dropped.

Definition at line 1523 of file connection.cpp.

tristate Connection::dropTable ( TableSchema tableSchema  ) 

Drops a table corresponding to the name in the given schema.

Drops a table defined by tableSchema (both table object as well as physically). If true is returned, schema information tableSchema is destoyed (because it's owned), so don't keep this anymore! No error is raised if the table does not exist physically

  • its schema is removed even in this case.
    Todo:
    (js): update any structure (e.g. query) that depend on this table!

Definition at line 1690 of file connection.cpp.

tristate Connection::dropTable ( const QString &  table  ) 

It is a convenience function, does exactly the same as bool dropTable( KexiDB::TableSchema* tableSchema )

Definition at line 1752 of file connection.cpp.

tristate Connection::alterTable ( TableSchema tableSchema,
TableSchema newTableSchema 
)

Todo:
(js): implement real altering

(js): update any structure (e.g. query) that depend on this table!

Definition at line 1764 of file connection.cpp.

bool Connection::alterTableName ( TableSchema tableSchema,
const QString &  newName,
bool  replace = false 
)

Alters name of table described by tableSchema to newName. If replace is true, destination table is completely dropped and replaced by tableSchema, if present. In this case, identifier of tableSchema becomes equal to the dropped table's id, what can be useful if tableSchema was created with a temporary name and ID (used in AlterTableHandler).

If replace is false (the default) and destination table is present -- false is returned and ERR_OBJECT_EXISTS error is set. The schema of tableSchema is updated on success.

Returns:
true on success.

Definition at line 1790 of file connection.cpp.

bool Connection::dropQuery ( QuerySchema querySchema  ) 

Drops a query defined by querySchema. If true is returned, schema information querySchema is destoyed (because it's owned), so don't keep this anymore!

Definition at line 1899 of file connection.cpp.

bool Connection::dropQuery ( const QString &  query  ) 

It is a convenience function, does exactly the same as bool dropQuery( KexiDB::QuerySchema* querySchema )

Definition at line 1933 of file connection.cpp.

bool Connection::removeObject ( uint  objId  ) 

Removes information about object with objId from internal "kexi__object" and "kexi__objectdata" tables.

Returns:
true on success.

Definition at line 1665 of file connection.cpp.

Field * Connection::findSystemFieldName ( FieldList fieldlist  ) 

Returns:
first field from fieldlist that has system name, null if there are no such field. For checking Driver::isSystemFieldName() is used, so this check can be driver-dependent.

Definition at line 1403 of file connection.cpp.

QString Connection::anyAvailableDatabaseName (  )  [virtual]

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:

  • value that previously had been set using setAvailableDatabaseName() for this connection, if it is not empty
  • else (2nd priority): value of DriverBehaviour::ALWAYS_AVAILABLE_DATABASE_NAME if it is not empty.

See decription of DriverBehaviour::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).

Definition at line 3120 of file connection.cpp.

void Connection::setAvailableDatabaseName ( const QString &  dbName  ) 

Sets dbName as name of a database that can be accessible. This is option that e.g. application that make use of KexiDB library can set to tune connection's behaviour when it needs to temporary connect to any database in the server to do some work. You can pass empty dbName - then anyAvailableDatabaseName() will try return DriverBehaviour::ALWAYS_AVAILABLE_DATABASE_NAME (the default) value instead of the one previously set with setAvailableDatabaseName().

See also:
anyAvailableDatabaseName()

Definition at line 3128 of file connection.cpp.

bool Connection::useTemporaryDatabaseIfNeeded ( QString &  tmpdbName  ) 

Because some engines need to have opened any database before executing administrative sql statements like "create database" or "drop database", this method is used to use appropriate, existing database for this connection. For file-based db drivers this always return true and does not set tmpdbName to any value. For other db drivers: this sets tmpdbName to db name computed using anyAvailableDatabaseName(), and if the name computed is empty, false is returned; if it is not empty, useDatabase() is called. False is returned also when useDatabase() fails. You can call this method from your application's level if you really want to perform tasks that require any used database. In such a case don't forget to closeDatabase() if returned tmpdbName is not empty.

Note: This method has nothing to do with creating or using temporary databases in such meaning that these database are not persistent

Definition at line 671 of file connection.cpp.

int KexiDB::Connection::lastInsertedAutoIncValue ( const QString &  aiFieldName,
const QString &  tableName,
Q_ULLONG *  ROWID = 0 
)

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 1414 of file connection.cpp.

bool Connection::executeSQL ( const QString &  statement  ) 

Executes query statement, but without returning resulting rows (used mostly for functional queries). Only use this method if you really need.

Definition at line 1055 of file connection.cpp.

QString Connection::selectStatement ( QuerySchema querySchema,
const QValueList< QVariant > &  params,
const SelectStatementOptions options = SelectStatementOptions() 
) const

Returns:
"SELECT ..." statement's string needed for executing query defined by querySchema and params.

Todo:
looking at singleTable is visually nice but a field name can conflict with function or variable name...

Add possibility for joining the values at client side.

Add possibility for joining the values at client side.

Todo:
add option that allows to omit "AS" keyword

Todo:
Add lookup schema option for separator other than ' ' or even option for placeholders like "Name ? ?"

Todo:
Add lookup schema option for separator other than ' ' or even option for placeholders like "Name ? ?"

Todo:
(js) add other sql parts

Definition at line 1067 of file connection.cpp.

bool Connection::storeObjectSchemaData ( SchemaData sdata,
bool  newObject 
)

Stores object's schema data (id, name, caption, help text) described by sdata on the backend. If newObject is true, new entry is created, and (when sdata.id() was <=0), new, unique object identifier is obtained and assigned to sdata (see SchemaData::id()).

If newObject is false, it's expected that entry on the backend already exists, so it's updated (changes to identifier are not allowed).

Returns:
true on success.

Todo:
safe to cast it?

Definition at line 2318 of file connection.cpp.

tristate Connection::loadObjectSchemaData ( int  objectID,
SchemaData sdata 
)

Added for convenience.

See also:
setupObjectSchemaData( const KexiDB::RowData &data, SchemaData &sdata ).
Returns:
true on success, false on failure and cancelled when such object couldn't

Definition at line 2298 of file connection.cpp.

tristate Connection::loadObjectSchemaData ( int  objectType,
const QString &  objectName,
SchemaData sdata 
)

Finds object schema data for object of type objectType and name objectName. If the object is found, resulted schema is stored in sdata and true is returned, otherwise false is returned.

Definition at line 2308 of file connection.cpp.

tristate Connection::loadDataBlock ( int  objectID,
QString &  dataString,
const QString &  dataID 
)

Loads (potentially large) data block (e.g. xml form's representation), referenced by objectID and puts it to dataString. The can be block indexed with optional dataID.

Returns:
true on success, false on failure and cancelled when there is no such data block
See also:
storeDataBlock().

Definition at line 2891 of file connection.cpp.

bool Connection::storeDataBlock ( int  objectID,
const QString &  dataString,
const QString &  dataID = QString::null 
)

Stores (potentially large) data block dataString (e.g. xml form's representation), referenced by objectID. Block will be stored in "kexi__objectdata" table and an optional dataID identifier. If there is already such record in the table, it's simply overwritten.

Returns:
true on success
See also:
loadDataBlock().

Definition at line 2901 of file connection.cpp.

bool Connection::removeDataBlock ( int  objectID,
const QString &  dataID = QString::null 
)

Removes (potentially large) string data (e.g. xml form's representation), referenced by objectID, and pointed by optional dataID.

Returns:
true on success. Does not fail if the block does not exist. Note that if dataID is not specified, all data blocks for this dialog will be removed.
See also:
loadDataBlock() storeDataBlock().

Definition at line 2923 of file connection.cpp.

void Connection::registerForTableSchemaChanges ( TableSchemaChangeListenerInterface listener,
TableSchema schema 
)

Register listener for receiving (listening) information about changes in TableSchema object.

Changes could be: altering and removing.

Definition at line 3475 of file connection.cpp.

virtual bool KexiDB::Connection::drv_containsTable ( const QString &  tableName  )  [pure virtual]

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

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

Implemented in KexiDB::MySqlConnection, KexiDB::pqxxSqlConnection, and KexiDB::SQLiteConnection.

bool Connection::drv_createTable ( const TableSchema tableSchema  )  [virtual]

Creates table using tableSchema information.

Returns:
true on success. Default implementation builds a statement using createTableStatement() and calls drv_executeSQL() Note for driver developers: reimplement this only if you want do to this in other way.
Moved to public for KexiMigrate.
Todo:
fix this after refactoring

Definition at line 1945 of file connection.cpp.

bool Connection::drv_alterTableName ( TableSchema tableSchema,
const QString &  newName 
) [virtual]

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 SQLite2, 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.
Moved to public for KexiProject.
Todo:
fix this after refactoring

Definition at line 1885 of file connection.cpp.

bool Connection::drv_dropTable ( const QString &  name  )  [virtual]

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

Moved to public for KexiMigrate

Todo:
fix this after refatoring

Definition at line 1677 of file connection.cpp.

virtual PreparedStatement::Ptr KexiDB::Connection::prepareStatement ( PreparedStatement::StatementType  type,
FieldList fields 
) [pure virtual]

Prepare a SQL statement and return a PreparedStatement instance.

Implemented in KexiDB::MySqlConnection, KexiDB::pqxxSqlConnection, and KexiDB::SQLiteConnection.

bool Connection::setupObjectSchemaData ( const RowData data,
SchemaData sdata 
)

Setups schema data for object that owns sdata (e.g. table, query) using cursor opened on 'kexi__objects' table, pointing to a record corresponding to given object.

Moved to public for KexiMigrate

Todo:
fix this after refatoring

Definition at line 2267 of file connection.cpp.

KexiDB::Field * Connection::setupField ( const RowData data  ) 

Returns:
a new field table schema for a table retrieved from data. Used internally by tableSchema().
Moved to public for KexiMigrate
Todo:
fix this after refatoring

Definition at line 2754 of file connection.cpp.

void Connection::destroy (  )  [protected]

Method to be called form Connection's subclass destructor.

See also:
~Connection()

Definition at line 214 of file connection.cpp.

tristate Connection::dropTable ( KexiDB::TableSchema tableSchema,
bool  alsoRemoveSchema 
) [protected]

Definition at line 1695 of file connection.cpp.

virtual bool KexiDB::Connection::drv_connect ( KexiDB::ServerVersionInfo version  )  [protected, pure virtual]

For reimplemenation: connects to database. version should be set to real server's version.

Returns:
true on success.

Implemented in KexiDB::MySqlConnection, KexiDB::pqxxSqlConnection, and KexiDB::SQLiteConnection.

virtual bool KexiDB::Connection::drv_disconnect (  )  [protected, pure virtual]

For reimplemenation: disconnects database

Returns:
true on success.

Implemented in KexiDB::MySqlConnection, KexiDB::pqxxSqlConnection, and KexiDB::SQLiteConnection.

virtual bool KexiDB::Connection::drv_executeSQL ( const QString &  statement  )  [protected, pure virtual]

Executes query statement, but without returning resulting rows (used mostly for functional queries). Only use this method if you really need.

Implemented in KexiDB::MySqlConnection, KexiDB::pqxxSqlConnection, and KexiDB::SQLiteConnection.

bool Connection::drv_getDatabasesList ( QStringList &  list  )  [protected, virtual]

For reimplemenation: 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.

Reimplemented in KexiDB::MySqlConnection, KexiDB::pqxxSqlConnection, and KexiDB::SQLiteConnection.

Definition at line 350 of file connection.cpp.

virtual bool KexiDB::Connection::drv_getTablesList ( QStringList &  list  )  [protected, pure virtual]

LOW LEVEL METHOD. For reimplemenation: loads low-level list of table names available for this connection. The names are in lower case. The method should return true only if there was no error on getting database names list from the server.

Implemented in KexiDB::MySqlConnection, KexiDB::pqxxSqlConnection, and KexiDB::SQLiteConnection.

bool Connection::drv_databaseExists ( const QString &  dbName,
bool  ignoreErrors = true 
) [protected, virtual]

For optional reimplemenation: 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 this appropriately 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.

Definition at line 356 of file connection.cpp.

virtual bool KexiDB::Connection::drv_createDatabase ( const QString &  dbName = QString::null  )  [protected, pure virtual]

For reimplemenation: creates new database using connection

Implemented in KexiDB::MySqlConnection, KexiDB::pqxxSqlConnection, and KexiDB::SQLiteConnection.

virtual bool KexiDB::Connection::drv_useDatabase ( const QString &  dbName = QString::null,
bool *  cancelled = 0,
MessageHandler msgHandler = 0 
) [protected, pure virtual]

For reimplemenation: opens existing database using connection

Returns:
true on success, false on failure and cancelled if user has cancelled this action.

Implemented in KexiDB::MySqlConnection, KexiDB::pqxxSqlConnection, and KexiDB::SQLiteConnection.

virtual bool KexiDB::Connection::drv_closeDatabase (  )  [protected, pure virtual]

For reimplemenation: closes previously opened database using connection.

Implemented in KexiDB::MySqlConnection, KexiDB::pqxxSqlConnection, and KexiDB::SQLiteConnection.

virtual bool KexiDB::Connection::drv_isDatabaseUsed (  )  const [inline, protected, virtual]

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 Connection::isDatabaseUsed() here or other things that "KexiDB 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 addtional chance to check for isDatabaseUsed(). Do not call this method from your driver's code, it should be used at KexiDB level only.

Reimplemented in KexiDB::pqxxSqlConnection.

Definition at line 928 of file connection.h.

virtual bool KexiDB::Connection::drv_dropDatabase ( const QString &  dbName = QString::null  )  [protected, pure virtual]

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

Implemented in KexiDB::MySqlConnection, KexiDB::pqxxSqlConnection, and KexiDB::SQLiteConnection.

QString Connection::createTableStatement ( const TableSchema tableSchema  )  const [protected]

Returns:
"CREATE TABLE ..." statement string needed for tableSchema creation in the database.
Note: The statement string can be specific for this connection's driver database, and thus not reusable in general.

Todo:
IS this ok for all engines?: if (!autoinc && !field->isPrimaryKey() && field->isNotNull())

Definition at line 870 of file connection.cpp.

QString Connection::selectStatement ( TableSchema tableSchema,
const SelectStatementOptions options = SelectStatementOptions() 
) const [protected]

Returns:
"SELECT ..." statement's string needed for executing query defined by "select * from table_name" where table_name is tableSchema's name. This method's variant can be useful when there is no appropriate QuerySchema defined.
Note: The statement string can be specific for this connection's driver database, and thus not reusable in general.

Definition at line 1397 of file connection.cpp.

bool Connection::drv_createTable ( const QString &  tableSchemaName  )  [protected, virtual]

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

Returns:
true on success

Definition at line 1952 of file connection.cpp.

virtual Q_ULLONG KexiDB::Connection::drv_lastInsertRowID (  )  [protected, pure virtual]

Returns:
unique identifier of last inserted row. Typically this is just primary key value. This identifier could be reused when we want to reference just inserted row. Note for driver developers: contact js (at) iidea.pl if your engine do not offers this information.

Implemented in KexiDB::MySqlConnection, KexiDB::pqxxSqlConnection, and KexiDB::SQLiteConnection.

TransactionData * Connection::drv_beginTransaction (  )  [protected, virtual]

Note for driver developers: begins new transaction and returns handle to it. Default implementation just executes "BEGIN" sql statement and returns just empty data (TransactionData object).

Drivers that do not support transactions (see Driver::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 TransactionData (declared in transaction.h) and return object of this subclass. You should return NULL if any error occurred. Do not check anything in connection (isConnected(), etc.) - all is already done.

Reimplemented in KexiDB::pqxxSqlConnection.

Definition at line 2178 of file connection.cpp.

bool Connection::drv_commitTransaction ( TransactionData trans  )  [protected, virtual]

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 in KexiDB::pqxxSqlConnection.

Definition at line 2186 of file connection.cpp.

bool Connection::drv_rollbackTransaction ( TransactionData trans  )  [protected, virtual]

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 in KexiDB::pqxxSqlConnection.

Definition at line 2191 of file connection.cpp.

bool Connection::drv_setAutoCommit ( bool  on  )  [protected, virtual]

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 behaviour 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()

Definition at line 2196 of file connection.cpp.

bool Connection::beginAutoCommitTransaction ( TransactionGuard tg  )  [protected]

Internal, for handling autocommited transactions: begins transaction if one is supported.

Returns:
true if new transaction started successfully or no transactions are supported at all by the driver or if autocommit option is turned off. A handle to a newly created transaction (or null on error) is passed to tg parameter.
Special case when used database driver has only single transaction support (Driver::SingleTransactions): and there is already transaction started, it is committed before starting a new one, but only if this transaction has been started inside Connection object. (i.e. by beginAutoCommitTransaction()). Otherwise, a new transaction will not be started, but true will be returned immediately.

Definition at line 1960 of file connection.cpp.

bool Connection::commitAutoCommitTransaction ( const Transaction trans  )  [protected]

Internal, for handling autocommited transactions: Commits transaction prevoiusly started with beginAutoCommitTransaction().

Returns:
true on success or when no transactions are supported at all by the driver.
Special case when used database driver has only single transaction support (Driver::SingleTransactions): if trans has been started outside Connection object (i.e. not by beginAutoCommitTransaction()), the transaction will not be committed.

Definition at line 1993 of file connection.cpp.

bool Connection::rollbackAutoCommitTransaction ( const Transaction trans  )  [protected]

Internal, for handling autocommited transactions: Rollbacks transaction prevoiusly started with beginAutoCommitTransaction().

Returns:
true on success or when no transactions are supported at all by the driver.
Special case when used database driver has only single transaction support (Driver::SingleTransactions): trans will not be rolled back if it has been started outside this Connection object.

Definition at line 2006 of file connection.cpp.

bool Connection::checkConnected (  )  [protected]

Helper: checks if connection is established; if not: error message is set up and false returned

Definition at line 293 of file connection.cpp.

bool Connection::checkIsDatabaseUsed (  )  [protected]

Helper: checks both if connection is established and database any is used; if not: error message is set up and false returned

Definition at line 303 of file connection.cpp.

KexiDB::TableSchema * Connection::setupTableSchema ( const RowData data  )  [protected]

Returns:
a full table schema for a table retrieved using 'kexi__*' system tables. Used internally by tableSchema() methods.

Definition at line 2798 of file connection.cpp.

KexiDB::QuerySchema * Connection::setupQuerySchema ( const RowData data  )  [protected]

Returns:
a full query schema for a query using 'kexi__*' system tables. Used internally by querySchema() methods.

Definition at line 2934 of file connection.cpp.

bool Connection::updateRow ( QuerySchema query,
RowData data,
RowEditBuffer buf,
bool  useROWID = false 
) [protected]

Update a row.

Todo:
perhaps we can try to update without using PKEY?

Definition at line 3150 of file connection.cpp.

bool Connection::insertRow ( QuerySchema query,
RowData data,
RowEditBuffer buf,
bool  getROWID = false 
) [protected]

Insert a new row.

Todo:
now only if PKEY is present, this should also work when there's no PKEY

Todo:
safe to cast it?

Todo:
show error

Todo:
remove just inserted row. How? Using ROLLBACK?

Todo:
show error

Definition at line 3234 of file connection.cpp.

bool Connection::deleteRow ( QuerySchema query,
RowData data,
bool  useROWID = false 
) [protected]

Delete an existing row.

Todo:
allow to delete from a table without pkey

Definition at line 3386 of file connection.cpp.

bool Connection::deleteAllRows ( QuerySchema query  )  [protected]

Delete all existing rows.

Definition at line 3452 of file connection.cpp.

bool Connection::setupKexiDBSystemSchema (  )  [protected]

Creates kexi__* tables.

Allocates all needed table KexiDB system objects for kexi__* KexiDB liblary's system tables schema. These objects are used internally in this connection and are added to list of tables (by name, not by id because these have no ids).

Definition at line 3032 of file connection.cpp.

TableSchema * Connection::newKexiDBSystemTableSchema ( const QString &  tsname  )  [protected]

used internally by setupKexiDBSystemSchema(): Allocates single table KexiDB system object named tsname and adds this to list of such objects (for later removal on closeDatabase()).

Definition at line 3009 of file connection.cpp.

QString KexiDB::Connection::escapeIdentifier ( const QString &  id,
int  escaping = Driver::EscapeDriver|Driver::EscapeAsNecessary 
) const [inline, protected]

Identifier escaping function in the associated Driver.

Calls the identifier escaping function in the associated Driver 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, kexi__* system tables and columns therein are not escaped

  • we assume these are valid identifiers for all drivers.

Definition at line 1118 of file connection.h.

void Connection::removeMe ( TableSchema ts  )  [protected]

Called by TableSchema -- signals destruction to Connection object To avoid having deleted table object on its list.

Definition at line 3112 of file connection.cpp.

tristate Connection::querySingleRecordInternal ( RowData data,
const QString *  sql,
QuerySchema query,
bool  addLimitTo1 = true 
) [protected]

Definition at line 2372 of file connection.cpp.

bool Connection::loadExtendedTableSchemaData ( TableSchema tableSchema  )  [protected]

Loads extended schema information for table tableSchema, if present (see ExtendedTableSchemaInformation in Kexi Wiki).

Returns:
true on success

Todo:
look at the current format version (KEXIDB_EXTENDED_TABLE_SCHEMA_VERSION)

Todo:
more properties

Todo:
more properties...

Definition at line 2655 of file connection.cpp.

bool Connection::storeExtendedTableSchemaData ( TableSchema tableSchema  )  [protected]

Stores extended schema information for table tableSchema, (see ExtendedTableSchemaInformation in Kexi Wiki). The action is performed within the current transaction, so it's up to you to commit. Used, e.g. by createTable(), within its transaction.

Returns:
true on success

Todo:
future: save in older versions if neeed

Definition at line 2594 of file connection.cpp.

virtual tristate KexiDB::Connection::drv_changeFieldProperty ( TableSchema table,
Field field,
const QString &  propertyName,
const QVariant &  value 
) [inline, protected, virtual]

This is a part of alter table interface implementing lower-level operations used to perform table schema altering. Used by AlterTableHandler.

Changes value of field property.

Returns:
true on success, false on failure, cancelled if the action has been cancelled.
Note for driver developers: implement this if the driver has to support the altering.

Reimplemented in KexiDB::SQLiteConnection.

Definition at line 1169 of file connection.h.


Friends And Related Function Documentation

friend class KexiDB::TableSchema [friend]

for removeMe()

Definition at line 1184 of file connection.h.

friend class KexiDB::DatabaseProperties [friend]

for setError()

Definition at line 1185 of file connection.h.


Member Data Documentation

cursors created for this connection

Definition at line 1175 of file connection.h.


The documentation for this class was generated from the following files:
KDE Home | KDE Accessibility Home | Description of Access Keys