[Cppcms-users] Is dbixx::row available in an associative arary?
Brought to you by:
artyom-beilis
From: augustin <aug...@ov...> - 2010-12-13 08:43:35
|
Hello, http://art-blog.no-ip.info/wikipp/en/page/ref_dbixx_row It's not too clear from the documentation above if the data in dbixx::row is available from an associative array. dbixx::result res; sql<<"SELECT name,age,birthday " "FROM person ", res; dbixx::row myRow; while (res.next(myRow)) { // Can we do something like the following? std::string name = myRow["name"]; // ... } My problem is that I want to pass the row data into my classes' constructors. Currently, I must declare temporary variables on the stack, extract the row data into those variables, and pass them to my object constructors: dbixx::row myRow; while (res.next(myRow)) { std::string tmp_name; int tmp_age, tmp_birthday; myRow >> tmp_name >> tmp_age >> tmp_birthday; // Call my class constructor: myClass person = myClass(tmp_name, tmp_age, tmp_birthday); } I'd be neater if we could do something like this: dbixx::row myRow; while (res.next(myRow)) { // Call my class constructor: myClass person = myClass(myRow["name"], myRow["age"], myRow["birthday"]); } I know there is the method fetch(): bool fetch(int idx,int &value); but again, it requires temporary variables to be created, adding to code bloat and overheads... :-/ Or how do you handle such things? Thanks, Augustin. -- Friends: http://www.reuniting.info/ http://activistsolutions.org/ My projects: http://astralcity.org/ http://3enjeux.overshoot.tv/ http://linux.overshoot.tv/ http://overshoot.tv/ http://charityware.info/ http://masquilier.org/ http://openteacher.info/ http://minguo.info/ http://www.wechange.org/ http://searching911.info/ . |