Hi,
Here is a BETA version of QxOrm 1.2.4 including the new feature you are waiting for (
QxOrm 1.2.4 BETA 14) :
http://www.qxorm.com/version/QxOrm_1.2.4_BETA_14.zipWith this version,
you can fetch many levels of relationships.
For example, using qxBlog tutorial, you can now write something like this if you want to fetch :
1- a blog with its author ;
2- for the author fetched, I want all blogs he has written ;
3- and for all blogs fetched, I want all comments associated.
- Code: Select all
blog_ptr blog_tmp = blog_ptr(new blog());
QSqlError daoError = qx::dao::fetch_by_id_with_relation("author_id->list_blog->list_comment", blog_tmp);
You can also create a list of relationships to fetch, like this :
- Code: Select all
blog_ptr blog_tmp = blog_ptr(new blog());
QStringList relation;
relation << "author_id->list_blog->list_comment";
relation << "author_id->list_blog->list_category";
relation << "list_comment";
relation << "list_category";
QSqlError daoError = qx::dao::fetch_by_id_with_relation(relation, blog_tmp);
To fetch all relationships per level, you can use the "*" keyword.
For examples, if you want to fetch all relationships with a depth of 3, you can write :
- Code: Select all
blog_ptr blog_tmp = blog_ptr(new blog());
QSqlError daoError = qx::dao::fetch_by_id_with_relation("*->*->*", blog_tmp);
Note : operator "->" between 2 relations means "
LEFT OUTER JOIN".
If you want to join 2 relations using "
INNER JOIN", you have to use the ">>" operator, for example :
- Code: Select all
blog_ptr blog_tmp = blog_ptr(new blog());
QSqlError daoError = qx::dao::fetch_by_id_with_relation("author_id>>list_blog>>list_comment", blog_tmp);
Now I need your help to test this BETA version, this new feature, and to be sure that there is no regression !Thanx in advance for all your future tests...
Note : I will write a documentation about this new feature...