[CDBI] How to acess data through manytomany

Bill Moseley moseley at hank.org
Wed Jan 4 19:03:54 GMT 2006


On Wed, Jan 04, 2006 at 05:28:41PM +0100, Bernard FRIT wrote:
> What I want is to get all the rows from "Livre" according to a search
> like criteria on "Sousrubrique" but all I can get is an iterator. Is
> there any way to populate an array
> of hashes containing all the essential columns (without any explicit
> programmation) ?

Hope I understand your question:

With Class::DBI::Sweet as your base class you can do joins in your search:

    @albums = Cd->search( { 'artists.artist.name' => $artist_name } );

That generates:


    SELECT me.id, me.title
    FROM   cd me, artist artist, artist_cd artists
    WHERE  ( artist.name = ? ) AND artists.artist = artist.id AND me.id = artists.cd


-- 
Bill Moseley
moseley at hank.org





More information about the ClassDBI mailing list