Re: [CDBI] Different subclasses for one table / Factory Pattern?
Oliver Jeeves <[email protected]>
| Newsgroups | gmane.comp.lang.perl.modules.class-dbi |
|---|---|
| Message-ID | <[email protected]> |
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? > > -Oli 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 first place. 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? -Oli _______________________________________________ ClassDBI mailing list ClassDBI-Ra3b/[email protected] http://lists.digitalcraftsmen.net/mailman/listinfo/classdbi
signature.asc
(application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (GNU/Linux) iD8DBQFFAXcHSbWXajvTQ+URAo+qAKCWa0Vj02l1Oo1YhMz3nXJGFcs8PQCgldAr fCeTHzDE/rVsknmHApa3fw4= =lDKk -----END PGP SIGNATURE-----