How to select all fields in a table? using wt::dbo::query.
Added by Rathnadhar K V almost 4 years ago
Namasthe,
My table has 21 columns (+2 added by Wt::Dbo).
I want all these columns as collection based on a complex and dynamic criteria.
I built the sql as thus:
std::string sql_query = "select * from open.tbl";
to this i append where conditions dynamically.
Finally execute the query as thus:
auto nse_company_information_records = bootstrap_handle~~get_database_session()~~>query(sql_query).
resultList(); //open_table_records is of type wt::dbo::collection ....
when I execute this, I get an exception.
please let me know how I can select all fields in the table row (based on a dynamic query) in wt::dbo.
Regards
Rathnadhar K V
Replies (1)
RE: How to select all fields in a table? using wt::dbo::query. - Added by Plug Gulp over 3 years ago
There is an excellent tutorial at https://www.webtoolkit.eu/wt/doc/tutorial/dbo.html#_querying_objects
The documentation for DBO Session gives some examples: https://www.webtoolkit.eu/wt/doc/reference/html/classWt_1_1Dbo_1_1Session.html#a1a9aff98561cd85ee82a11a57e1e7a74
I think for Session::query you have to have a Dbo::ptr as template parameter, where as for a Session::find the parameter is not a pointer.
https://www.webtoolkit.eu/wt/doc/reference/html/classWt_1_1Dbo_1_1Session.html#a8cad70bef9cffd6613107d5cd3aeb16a
https://www.webtoolkit.eu/wt/doc/reference/html/classWt_1_1Dbo_1_1Session.html#a1a9aff98561cd85ee82a11a57e1e7a74
HTH