Specific Fields in a Query

Forum for posting problems using QxOrm library

Specific Fields in a Query

Postby Ioio » Fri Aug 05, 2011 3:45 pm

Hi, how can i make a query with specific fields from different databases, not all table information. How can i create a dynamic object to handle only these specific information.
Thanks
Ioio
 

Re: Specific Fields in a Query

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

Hi,

For specific fields, you have to use the parameter const QStringList & columns for functions into namespace qx::dao.
The list of functions is available here :
http://www.qxorm.com/doxygen/html/group___qx_dao.html

Here a code of qxBlog project :
Code: Select all
// Fetch only property 'm_dt_creation' of blog
QStringList lstColumns = QStringList() << "date_creation";
list_blog lst_blog_with_only_date_creation;
daoError = qx::dao::fetch_all(lst_blog_with_only_date_creation, NULL, lstColumns);
QxOrm admin
 

Re: Specific Fields in a Query

Postby Ioio » Wed Aug 17, 2011 1:04 pm

Thanks for your answer, it's clear. But, in the same example, if i want only a query with the following fields: Category_id, Category_Name, Blog_Text, and Author_name, should i use QStringList with the name of three different tables? Another question is, do you have a tool for autogenerate headers, relations, data type, etc from database, maybe using QtSql and QSqlDrive?
Thanks so much.
By
Ioio
 

Re: Specific Fields in a Query

Postby QxOrm admin » Thu Aug 18, 2011 7:51 am

if i want only a query with the following fields: Category_id, Category_Name, Blog_Text, and Author_name, should i use QStringList with the name of three different tables?

No, when you want to query the database using more than 1 table (so you have some relations), you cannot specify columns to fetch. This is not supported by QxOrm library yet (version 1.1.7).
For your relations, you can :
1- lazy fetch (only id of each object are fetched, using qx::dao::fetch_all for example)
2- eager fetch (all properties of each object are fetched) => you can specify relations to eager fetch (using qx::dao::fetch_all_with_relation) or you can eager fetch all relations (using qx::dao::fetch_all_with_all_relation)

Another question is, do you have a tool for autogenerate headers, relations, data type, etc from database, maybe using QtSql and QSqlDrive?

There is no tool today to auto-generate some files.
It could be interesting, perhaps in a future release, I don't know yet...
QxOrm admin
 


Return to QxOrm - Help

Who is online

Users browsing this forum: No registered users and 12 guests

cron