Max Min in QxORM

Forum for posting problems using QxOrm library

Max Min in QxORM

Postby mtfk » Thu Aug 04, 2011 1:01 pm

Hi,

How can I make query to get min, max value from table?
some thing like that:
"SELECT MAX(id) FROM BOOKS;"

I just found on this forum, that creating complex query is right now impossible - QxOrm (version 1.1.3) but it was quite old post.
Any thing in this topic has change?

If not anyone can show some example how to use directly QtSql query (can I use the same connection that I opened by QxOrm or I need create new one?)

Thanks a lot of any advice.
mtfk
 

Re: Max Min in QxORM

Postby QxOrm admin » Sat Aug 06, 2011 2:43 pm

Hi,

To create complex SQL query, you have to use QtSql module.
This is not supported yet by QxOrm library (version 1.1.7).

To use the same connexion that QxOrm opened, you need the singleton qx::QxSqlDatabase :
Code: Select all
qx::QxSqlDatabase::getDatabase()

This code returns a QSqlDatabase object of Qt library : this is the connexion used by QxOrm library (for current thread).

If not anyone can show some example how to use directly QtSql query

You have a lot of sample on the web.
Here a quick sample :
Code: Select all
QSqlDatabase db = qx::QxSqlDatabase::getDatabase();
QSqlQuery   query("SELECT etc...", db);
bool ok = query.exec();
QxOrm admin
 


Return to QxOrm - Help

Who is online

Users browsing this forum: No registered users and 3 guests

cron