[CDBI] CDBI "collections" and Class::DBI::Iterator

Perrin Harkins perrin at elem.com
Sun Aug 27 20:34:08 BST 2006


Tom Metro wrote:
> I had a need to write some methods that operated on collections of CDBI 
> records, and wondered what was the preferred approach and in what module 
> those methods should live.

They go in the class that you want to end up with objects from.

> In the existing code I was working on there was a parent record type and 
> a child record type with a parent->has_many(child) type relationship set 
> up. The methods for dealing with bunches of child records currently 
> lived in the parent class, which seemed out of place.

I'd put the custom SQL methods in the child and maybe add methods in the 
parent that call the new methods in the child.

- Perrin



More information about the ClassDBI mailing list