[Dbix-class] all data at once
Angel Kolev
ankolev at gmail.com
Wed Dec 12 15:15:02 GMT 2007
Hi, i need genders in different tables. I forgot to notice, found
solution for my problem:
my $rs = $c->model('AppModelDB::Family')->search({family_id =>
undef},{join => ['female','male'],
prefetch => ['female','male']
});
$rs->populate([{female=>{%females},%family,male=>{%males},}]);
Hartmaier Alexander wrote:
>
> Hi!
>
>
>
> Why isn‘t the gender a simple attribute but instead two different tables?
>
>
>
> -Alex
>
>
>
> *From:* Angel Kolev [mailto:ankolev at gmail.com]
> *Sent:* Saturday, December 08, 2007 4:37 PM
> *To:* dbix-class at lists.scsys.co.uk
> *Subject:* [Dbix-class] all data at once
>
>
>
> Hi, All. Im new in DBIx::Class and this is my first question here :)
> I write catalyst app and use dbic for 3 tables (males,females,family)
> with has_many and may_to_many. All works, but there are too many
> requests to my database when i use this:
> my $rs = $c->model('AppModelDB::ClientMale')->search();
> while (my $line = $rs->next) {
> push @{$families},[ $line->client_family->first->id,
> make_family(
> $line->first_n,
> $line->family_n,
> $line->client_female->first->first_n,
> $line->client_female->first->family_n
> )
> ,$line->client_family->first->city
> ,$line->client_family->first->zip_code
> ,$line->client_family->first->municipality
> ,$line->client_family->first->street
> ,$line->client_family->first->public_place_type
> ,$line->client_family->first->public_place_name
> ];
> }
> }
> $c->stash->{families} = $families;
>
> I wrote "export DBIC_TRACE=1" for debug and saw alot of screens with
> SELECT requests to MySQL. Plese help me to optimize the code. Every
> single table has around 190 lines.
> Thank you
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.rawmode.org
More information about the DBIx-Class
mailing list