From qxBlog tutorial, imagine that you have a blog instance, and this blog contains a list of comments.
To save it into database, you can save first your blog, and then the list of comments, like this :
- Code: Select all
daoError = qx::dao::insert(my_blog);
daoError = qx::dao::insert(my_list_of_comments);
Or you can use the '
insert_with_all_relation()' function, and you have only 1 line of code with the same behaviour :
- Code: Select all
daoError = qx::dao::insert_with_all_relation(my_blog);
*
qx::dao::insert => save only 1 table.
*
qx::dao::insert_with_all_relation => save parent table and all its relations.
Moreover, there is an automatic mechanism of
commit/rollback if you use
insert_with_all_relation() (nothing saved if there is an error during process).
To have a
commit/rollback mechanism using
insert function, you can use a session (
qx::QxSession class), goto here for more details about this feature :
http://www.qxorm.com/qxorm_en/faq.html#faq_170