Hey,
2010/7/24 E L <[email protected]>:
> Is it possible to specify a data structure where the hierarchy is the
> same table? For example, a bill of material has "parts" contain other
> parts, but all the parts are still in the same table. I tried to
> specify the dbo class as shown below, but that causes the program to
> crash when session::createTables() is called. Is there a way to do
> this?
Crashing is Wt::Dbo's unmature way to tell you that something is wrong.
This should work (as is done for the Comment class in the blog example):
> Also, is is possible to place a NULL value in the database using wt::dbo?
Yes, use boost::optional<T>
> class Part;
> namespace dbo = Wt::Dbo;
> class Part : public dbo::Dbo {
> public:
> dbo::ptr<Part> parent;
dbo::collection< dbo::ptr<Part> > children;
> std::string refdes;
> std::string value;
>
> template<class Action>
> void persist(Action& a) {
> dbo::belongsTo(a, parent, "part");
dbo::hasMany(a, children, "part");
> dbo::field(a, refdes, "refdes");
> dbo::filed(a, value, "value");
> }
> };
> DBO_EXTERN_TEMPLATES(Part);
>
Regards,
koen
------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest