Dbo::field map access
Added by Alistair Lowe over 11 years ago
Hi guys,
On my website I have a text search box and a column selection box so for example I may wish to search for "hello 1" in the "Description" column.
My issue is that when I feed my search string into Witty's .bind() in the query, it's not type-aware of the column and treats all search text as a string, even though some columns are other data types.
Is it at all possible to gain access to the variable/string relations formed by Dbo::field? Or is there some other approach I could take to this issue?
Many thanks
Replies (3)
RE: Dbo::field map access - Added by Koen Deforche over 11 years ago
Hey Alistair,
You can use Query::fields() for a query that (would) select the object, e.g.
fields = session.find<Table>().fields()
Regards,
koen
RE: Dbo::field map access - Added by Alistair Lowe over 11 years ago
Hi Koen,
Apologies for the late reply, have been pulled off onto other matters as usual.
I give this code a try and it bombs out the debugger so I can't even pin-point where an error may have occurred.
std::vector<dbo::FieldInfo> temp = session->find<LinkBox>().fields();
Must I inherit from a certain class when constructing my dbo table class for this to work? Currently I have this:
class LinkBox : public dbo::Dbo<LinkBox>
{
public:
// Database Attributes
Wt::WString description;
Wt::WString UUID;
int numberOfLinks;
Wt::WString location;
// Database Relationships
dbo::collection< dbo::ptr<LinkBoxSwitch> > linkBoxSwitches;
// Database Functions
template<class Action>
void persist( Action &a )
{
dbo::field( a, description, "Description" );
dbo::field( a, UUID, "UUID" );
dbo::field( a, numberOfLinks, "Number of Links" );
dbo::field( a, location, "Location" );
dbo::hasMany( a, linkBoxSwitches, dbo::ManyToOne, "LinkBox" );
}
};
Many thanks
RE: Dbo::field map access - Added by Alistair Lowe over 11 years ago
Hoho never mind,
I've implemented a different approach via session but I think the issue was actually a bug in GDB and C for Ubuntu 13.04, had to downgrade GDB to the version that runs on 12.10.