|
|
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 QCString &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.
void setPassword (const QString &pwd)
| setPassword |
Change 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 QCString & version ()
| version |
[const]
Get version of connection.
const QCString & provider ()
| provider |
[const]
Get provider of connection.
QString description (bool version=true)
| 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 parse (const QString &sql)
| parse |
Parse a query on an actual connection and report any syntax problems encountered. Defaults to not implemented.
Parameters:
conn | Connection to execute on. |
sql | SQL to parse |
void parse (const toSQL &sql)
| parse |
Parse a query on an actual connection and report any syntax problems encountered. Defaults to not implemented.
Parameters:
conn | Connection to execute on. |
sql | SQL to parse |
void execute (const 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 (const 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 (const 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 (const 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 (QObject *widget)
| addWidget |
Add a object 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 (QObject *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.
void addIfNotExists (objectName &object)
| addIfNotExists |
Add a new object to the objectlist if it doesn't exist already.
Parameters:
object | The object to add |
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 synonyms,bool block=false,bool need=true)
| cacheAvailable |
Check if cache is available or not.
Parameters:
synonyms | If synonyms are needed or not. |
block | Block until cache is done. |
true | True if you need the cache, or just checking. |
Returns: True if cache is available.
void cancelAll (void)
| cancelAll |
Try to stop all running queries.
bool loadDiskCache (void)
| loadDiskCache |
load disk cache
void writeDiskCache (void)
| writeDiskCache |
write disk cache
std::list<QString> running (void)
| running |
Get a list of currently running SQL.
void logMessage (QString text)
| logMessage |
friend class toQuery | toQuery |