Re: [Cppcms-users] Loading data into forms
Brought to you by:
artyom-beilis
From: Artyom B. <art...@ya...> - 2012-01-30 08:21:09
|
> From: "ele...@ex..." <ele...@ex...> > Hi, Hello, > > I've just recently started experimenting with cppcms and so far I quite > like it. (thanks!) > > I've been studying the message board code in the examples section to get > my head around things and at the same time developing a simple blog > application. > BTW there is a blog application in svn http://cppcms.svn.sourceforge.net/viewvc/cppcms/blog/trunk/ This once runs CppCMS blog. > My question is this - what is the best way to load data from database into > a typical edit form, make it available for user to edit and submit > changes? > > One way I think I could do it is simply cpdbb::result >> user.id >> > user.name >> user.title etc and then copy the values into the members of > the form struct. > > Is this the preferred way or is there another? > > Should this be done in the controller or elsewhere? Honestly whatever feels right. You may create some set of "model" classes over cppdb and then set the values to the form from this model. You may use temporary variables. You can call. cppdb::result r = ... my_from.name.value(r.get<std::string>(0)); my_from.title.value(r.get<std::string>(1)); And so on. Its really up to you. Some users create some set of model classes and separate them from controller some use directly SQL in controller and setup their content. Whatever feels right > > Thanks, > Petr > > Best, Artyom Beilis ------------- Support CppCMS by donating money: https://sourceforge.net/donate/index.php?group_id=209965 |