nah, i'd rather use QtSql library.
________________________________
From: Nagaev Boris <[email protected]>
To: Oto Magaldadze <[email protected]>
Cc: "[email protected]"
<[email protected]>
Sent: Friday, April 27, 2012 1:44 PM
Subject: Re: [Wt-interest] link WTableView to sql table
yes, if you want use Dbo, you should create a class per model
On Fri, Apr 27, 2012 at 13:31, Oto Magaldadze <[email protected]> wrote:
> oh maan so i need to create a separate class to each of the tables i need to
> connect to ?? :((
>
> ________________________________
> From: Nagaev Boris <[email protected]>
> To: Oto Magaldadze <[email protected]>;
> [email protected]
> Sent: Friday, April 27, 2012 12:50 PM
> Subject: Re: [Wt-interest] link WTableView to sql table
>
> Hello!
>
> In QueryModel, Result may be dbo::ptr<YourClass> (or boost::tuple of
> such dbo::ptr's if you use SQL JOIN).
>
> To tell QueryModel, which fields to use, call addColumn method for
> each field, or use addAllFieldsAsColumns() to add all fields as
> columns.
>
> Then setQuery(session.find<YourClass>()) to ad all records from
> database table to this model/view.
>
> Here YourClass is a C++ class, representing a record, for example:
>
> class User {
> public:
> std::string name;
> std::string password;
>
> template<class Action>
> void persist(Action& a)
> {
> dbo::field(a, name, "name");
> dbo::field(a, password, "password");
> }
> };
>
> On Fri, Apr 27, 2012 at 10:25, Oto Magaldadze <[email protected]> wrote:
>> In Qt if i want to display sql table content in view i can do this:
>> QSqlTableModel model;
>> model.setTable("Table1");
>> model.select();
>>
>> QTableView view;
>> view.setModel(&model);
>>
>> And how do I do that in Wt, 'cause I am stuck with Wt::Dbo::QueryModel<
>> Result > and Wt::Dbo::Query< Result, BindStrategy >, really can't get why
>> is
>> there <Result> stuff, what is it needed for, isn't there a way to
>> .setTable(std:str tablename)?
>>
>>
>> Oto
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Live Security Virtual Conference
>> Exclusive live event will cover all the ways today's security and
>> threat landscape has changed and how IT managers can respond. Discussions
>> will include endpoint security, mobile security and the latest in malware
>> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>> _______________________________________________
>> witty-interest mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/witty-interest
>>
>
>------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest