aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules/objects/class_sql.cpp
diff options
context:
space:
mode:
authorGravatar Noldor2010-06-21 15:46:45 +0000
committerGravatar Noldor2010-06-21 15:46:45 +0000
commited9dd025690aa6d01e3408f26ed625241d09ac27 (patch)
treebc0bf5381c29204c8ffd48fd8ff70cf06b2fc1ac /src/modules/objects/class_sql.cpp
parentAdditional fix related to script popups (diff)
downloadKVIrc-ed9dd025690aa6d01e3408f26ed625241d09ac27.tar.gz
KVIrc-ed9dd025690aa6d01e3408f26ed625241d09ac27.tar.bz2
KVIrc-ed9dd025690aa6d01e3408f26ed625241d09ac27.zip
Some fixes + docs updating + some little code improvements in objects module
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@4491 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src/modules/objects/class_sql.cpp')
-rw-r--r--src/modules/objects/class_sql.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/modules/objects/class_sql.cpp b/src/modules/objects/class_sql.cpp
index a08e88868..9755cb020 100644
--- a/src/modules/objects/class_sql.cpp
+++ b/src/modules/objects/class_sql.cpp
@@ -101,6 +101,8 @@ static void KviKvsSqlInstanceUnregister(KviKvsObject_sql *instance)
Closes the connection <connection_name>.
!fn: <size:integer> $queryResultsSize()
Returns the query size in rows or -1 if the query is empty or the database driver doesn' support the function.
+ !fn: <error:string> $lastError(<more_details:boolean>)
+ Returns last error occurred. Use the more_details flag for more info about the error.
!fn: <ok:boolean> $queryExec([<query:string>])
Execs the current query <query>. The string must follow the right syntax against the database in use.
If there are no parameters, it will exec the query previously done.
@@ -545,12 +547,20 @@ KVSO_CLASS_FUNCTION(sql,queryRecord)
KVSO_CLASS_FUNCTION(sql,lastError)
{
CHECK_QUERY_IS_INIT
- QString szError;
+ bool bMoreErrorDetails;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("more",KVS_PT_BOOLEAN,KVS_PF_OPTIONAL,bMoreErrorDetails)
+ KVSO_PARAMETERS_END(c)
+ QString szError;
QSqlError error=m_pCurrentSQlQuery->lastError();
- if (error.type()==QSqlError::StatementError) szError="SyntaxError";
- else if (error.type()==QSqlError::ConnectionError) szError="ConnectionError";
- else if (error.type()==QSqlError::TransactionError) szError="TransactionError";
- else szError="UnkonwnError";
+ if (bMoreErrorDetails) szError=error.text();
+ else
+ {
+ if (error.type()==QSqlError::StatementError) szError="SyntaxError";
+ else if (error.type()==QSqlError::ConnectionError) szError="ConnectionError";
+ else if (error.type()==QSqlError::TransactionError) szError="TransactionError";
+ else szError="UnkonwnError";
+ }
c->returnValue()->setString(szError);
return true;
}