# class toConnection

Represent a database connection in TOra. More...

Definition | `#include <toconnection.h>`
List of all Methods

Annotated List
Files
Globals
Hierarchy
Index

#### Public Types

- class exception
- struct objectName
- class connectionImpl

#### Public Methods

- toConnection (const QString &provider,const QString &user,const QString &password, const QString &host,const QString &database,const QString &mode=QString::null, bool cache=true)
- toConnection (const toConnection &conn)
- virtual ~toConnection ()
- bool closeWidgets (void)
- const QString & user () const
- const QString & password () const
- const QString & host () const
- const QString & database () const
- const QString & mode () const
- const QString & version () const
- const QString & provider () const
- virtual QString description (void) const
- void setNeedCommit (bool needCommit=true)
- bool needCommit (void) const
- virtual void commit (void)
- virtual void rollback (void)
- void execute (toSQL &sql, toQList ¶ms)
- void execute (const QString &sql, toQList ¶ms)
- void execute (toSQL &sql, const QString &arg1=QString::null,const QString &arg2=QString::null, const QString &arg3=QString::null,const QString &arg4=QString::null, const QString &arg5=QString::null,const QString &arg6=QString::null, const QString &arg7=QString::null,const QString &arg8=QString::null, const QString &arg9=QString::null)
- void execute (const QString &sql, const QString &arg1=QString::null,const QString &arg2=QString::null, const QString &arg3=QString::null,const QString &arg4=QString::null, const QString &arg5=QString::null,const QString &arg6=QString::null, const QString &arg7=QString::null,const QString &arg8=QString::null, const QString &arg9=QString::null)
- void allExecute (toSQL &sql, toQList ¶ms)
- void allExecute (const QString &sql, toQList ¶ms)
- void allExecute (toSQL &sql, const QString &arg1=QString::null,const QString &arg2=QString::null, const QString &arg3=QString::null,const QString &arg4=QString::null, const QString &arg5=QString::null,const QString &arg6=QString::null, const QString &arg7=QString::null,const QString &arg8=QString::null, const QString &arg9=QString::null)
- void allExecute (const QString &sql, const QString &arg1=QString::null,const QString &arg2=QString::null, const QString &arg3=QString::null,const QString &arg4=QString::null, const QString &arg5=QString::null,const QString &arg6=QString::null, const QString &arg7=QString::null,const QString &arg8=QString::null, const QString &arg9=QString::null)
- void addWidget (QWidget *widget)
- void delWidget (QWidget *widget)
- void addInit (const QString &sql)
- void delInit (const QString &sql)
- QString quote (const QString &name)
- QString unQuote (const QString &name)
- std::list<objectName> & objects (bool block)
- std::map<QString,objectName> & synonyms (bool block)
- toQDescList & columns (const objectName &table,bool nocache=false)
- void rereadCache (void)
- const objectName & realName (const QString &object,bool block)
- const objectName & realName (const QString &object,QString &synonym,bool block)
- bool cacheAvailable (bool block=false,bool need=true)

#### Public Members

- friend class toQuery

## Detailed Description

Represent a database connection in TOra. Observe that this can mean several actual connections to the database as queries that ae expected to run a long time are sometimes executed in their own connection to make sure the interface doesn't lock up for a long time.

exception (class)

### exception

Class that could be used to throw exceptions in connection errors. Must use if you want to indicate error offset.

objectName (struct)

### objectName

Contain information about a tablename.

connectionImpl (class)

### connectionImpl

This class is an abstract baseclass to actually implement the comunication with the database. (See also toQuery::queryImpl and toConnectionProvider)

toConnection (const QString &provider,const QString &user,const QString &password, const QString &host,const QString &database,const QString &mode=QString::null, bool cache=true)

### toConnection

Create a new connection.

Parameters:

provider | Which database provider to use for this connection. (See to toDatabaseConnection)
user | User to connect to the database with.
password | Password to connect with.
host | Host to connect to the database with.
database | Database to connect to.
mode | Mode to connect to the database with.
cache | Enable object cache for this connection.

toConnection (const toConnection &conn)

### toConnection

Create a copy of a connection. Will not cache objects, so objects will never be available in a subconnection.

Parameters:

conn | Connection to copy.

~toConnection ()

### ~toConnection

[virtual]

Destroy connection.

bool closeWidgets (void)

### closeWidgets

Try to close all the widgets associated with this connection.

Returns: True if all widgets agreed to close.

const QString & user ()

### user

[const]

Get username of connection.

const QString & password ()

### password

[const]

Get password of connection.

const QString & host ()

### host

[const]

Get host of connection.

const QString & database ()

### database

[const]

Get database of connection.

const QString & mode ()

### mode

[const]

Get mode of connection.

const QString & version ()

### version

[const]

Get version of connection.

const QString & provider ()

### provider

[const]

Get provider of connection.

QString description (void)

### description

[const virtual]

Get a description of this connection.

void setNeedCommit (bool needCommit=true)

### setNeedCommit

Set if this connection needs to be commited.

bool needCommit (void)

### needCommit

[const]

Get information about if the connection has uncommited data.

Returns: Whether uncommited data is available.

void commit (void)

### commit

[virtual]

Commit connection. This will also close all extra connections except one.

void rollback (void)

### rollback

[virtual]

Rollback connection. This will also close all extra connections except one.

void execute (toSQL &sql, toQList ¶ms)

### execute

Execute a statement without caring about the result.

Parameters:

sql | SQL to execute
params | Parameters to pass to query.

void execute (const QString &sql, toQList ¶ms)

### execute

Execute a statement without caring about the result.

Parameters:

sql | SQL to execute
params | Parameters to pass to query.

void execute (toSQL &sql, const QString &arg1=QString::null,const QString &arg2=QString::null, const QString &arg3=QString::null,const QString &arg4=QString::null, const QString &arg5=QString::null,const QString &arg6=QString::null, const QString &arg7=QString::null,const QString &arg8=QString::null, const QString &arg9=QString::null)

### execute

Execute a statement without caring about the result.

Parameters:

sql | SQL to execute
arg1 | Parameters to pass to query.

void execute (const QString &sql, const QString &arg1=QString::null,const QString &arg2=QString::null, const QString &arg3=QString::null,const QString &arg4=QString::null, const QString &arg5=QString::null,const QString &arg6=QString::null, const QString &arg7=QString::null,const QString &arg8=QString::null, const QString &arg9=QString::null)

### execute

Execute a statement without caring about the result.

Parameters:

sql | SQL to execute
arg1 | Parameters to pass to query.

void allExecute (toSQL &sql, toQList ¶ms)

### allExecute

Execute a statement without caring about the result on all open database connections.

Parameters:

sql | SQL to execute
params | Parameters to pass to query.

void allExecute (const QString &sql, toQList ¶ms)

### allExecute

Execute a statement without caring about the result on all open database connections.

Parameters:

sql | SQL to execute
params | Parameters to pass to query.

void allExecute (toSQL &sql, const QString &arg1=QString::null,const QString &arg2=QString::null, const QString &arg3=QString::null,const QString &arg4=QString::null, const QString &arg5=QString::null,const QString &arg6=QString::null, const QString &arg7=QString::null,const QString &arg8=QString::null, const QString &arg9=QString::null)

### allExecute

Execute a statement without caring about the result on all open database connections.

Parameters:

sql | SQL to execute
arg1 | Parameters to pass to query.

void allExecute (const QString &sql, const QString &arg1=QString::null,const QString &arg2=QString::null, const QString &arg3=QString::null,const QString &arg4=QString::null, const QString &arg5=QString::null,const QString &arg6=QString::null, const QString &arg7=QString::null,const QString &arg8=QString::null, const QString &arg9=QString::null)

### allExecute

Execute a statement without caring about the result on all open database connections.

Parameters:

sql | SQL to execute
arg1 | Parameters to pass to query.

void addWidget (QWidget *widget)

### addWidget

Add a widget that uses this connection. This is needed to ensure that all widgets that make use of a connection are destroyed when the connection is closed. Usually tool windows need to call this function.

Parameters:

widget | The widget to add to the connection.

void delWidget (QWidget *widget)

### delWidget

Remove a widget from this connection. Should be called by the destructor of the widget that has called addWidget.

Parameters:

widget | Widget to remove from the widget list.

See also: addWidget

void addInit (const QString &sql)

### addInit

Add a statement to be run uppon making new connections.

Parameters:

sql | Statement to run.

void delInit (const QString &sql)

### delInit

Remove a statement that was added using addInit.

QString quote (const QString &name)

### quote

Return a string representation to address an object.

Parameters:

name | The name to be quoted.

Returns: String addressing table.

QString unQuote (const QString &name)

### unQuote

Perform the opposite of quote.

Parameters:

name | The name to be un-quoted.

Returns: String addressing table.

std::list<objectName> & objects (bool block)

### objects

Get the objects available for the current user. Do not modify the returned list.

Parameters:

block | Indicate wether or not to block until cached objects are available.

Returns: A list of object available for the current user. The list is sorted in owner and name order.

std::map<QString,objectName> & synonyms (bool block)

### synonyms

Get the synonyms available for objects. Do not modify the returned list.

Parameters:

block | Indicate wether or not to block until cached objects are available.

Returns: A list of synonyms to objects available for the current user.

toQDescList & columns (const objectName &table,bool nocache=false)

### columns

Get a list of the available columns for a table. This function caches the responses and should be fairly fast after the first call. Do not modify the returned list.

Parameters:

table | The table to describe.
nocache | Don't use cached values even if they are available.

Returns: A list of the columns for a table.

void rereadCache (void)

### rereadCache

Reread the object and column cache.

const objectName & realName (const QString &object,bool block)

### realName

Get the real object name of an object.

Parameters:

object | Object name
block | Block if not done caching object.

const objectName & realName (const QString &object,QString &synonym,bool block)

### realName

Get the real object name of a synonym.

Parameters:

object | Object name
synonym | Filled with the synonym used to access the object returned or empty.
block | Block if not done caching object.

bool cacheAvailable (bool block=false,bool need=true)

### cacheAvailable

Check if cache is available or not.

Parameters:

block | Block until cache is done.
true | True if you need the cache, or just checking.

Returns: True if cache is available.

friend class toQuery

### toQuery