[CDBI] Different subclasses for one table / Factory Pattern?
oj at defuturo.co.uk
Fri Sep 8 14:58:26 BST 2006
Oliver Jeeves wrote:
> This seems to work ok.
> My question is; can I add extra might_have relationships to the
> subclasses? Is there any reason why this wouldn't work (eg. does the
> code need to know about them when the object is initialised)? Is the
> behaviour of doing this sort of thing likely to change in the future?
In answer to my own question; no. You don't seem to be able to do this
sort of thing with CDBI.
I get the error:
DBD::SQLite::db prepare_cached failed: no such column: test(1) at
dbdimp.c line 269 at /usr/lib/perl5/vendor_perl/5.8.5/Ima/DBI.pm line 381.
When trying to access a might_have relationship added by a class that a
CDBI object was re-blessed into.
Which is a shame, but it did seem like a pretty hairy thing to do in the
However, this leads naturally to my next question; how do I achieve this
sort of thing?
Currently, I'm thinking of having the base class call retrieve on the
derived class, which will probably mean extra DB lookups, but will
definatly work. Does anyone have a better solution?
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 189 bytes
Desc: OpenPGP digital signature
Url : http://lists.digitalcraftsmen.net/pipermail/classdbi/attachments/20060908/0ed3e164/signature.pgp
More information about the ClassDBI