in reply to Re: No Fear: decoupling your application from the database
in thread No Fear: decoupling your application from the database

I've used the join facility in Alzabo for only trivial things but so far it handles things ok.

I've just altered the node and added an example from my own code where I use Alzabo's join facility. You'll see it right inside the while() loop.

sub display_address { my $self = shift; my $tmpl = $self->load_tmpl( 'display_address.tmpl' ); my $schema = $self->param( 'schema' ); my $q = $self->query; # Retrieve the parameters my $street = $q->param( 'street' ); my $house = $q->param( 'house' ); my @people; { my $roster = $schema->Roster; my $history = $schema->History; my $roster_fk = $history->RosterFk; my $election = $schema->Election; my $election_date = $election->Date; my $election_desc = $election->Desc; my $people = $roster->rows_where( where => [ [ $roster->StreetFk, '=', $street ], [ $roster->HouseNumber, '=', $house ] ], order_by => [ $roster->Name ] ); # Retrieve the result set into an array while (my $person = $people->next) { my @votes = $schema->join( join => [ $history, $election ], select => [ $election ], where => [ $roster_fk, '=', $person->SosId ], order_by => [ $election_date, $election_desc ], )->all_rows; # Fetch the values from the selected data @votes = map $_->Date.': '.$_->Desc, @votes; push @people, { History => join("<br />",@votes), Name => $person->Name }; } } $tmpl->param('people', \ @people); return $tmpl->output; }

Replies are listed 'Best First'.
Re: Re: Re: No Fear: decoupling your application from the database
by autarch (Hermit) on Mar 27, 2003 at 00:32 UTC

    Alzabo also does outer joins pretty simply. At least, it's simple in terms of scaling up from the complexity of a non-outer join example. There's still that initial learning curve and all ;)

    my $cursor = $schema->join ( select => [ $table1, $table2 ], join => [ [ left_outer_join => $table1 => $table2 ], [ $table2 => $table3 ], ], ... );

    The current CVS version also adds support for specifying join conditions as in this SQL:

    SELECT ... FROM Foo OUTER JOIN Bar on Bar.foo_id = Foo.foo_id AND Bar.size > 2 WHERE ...

    The Alzabo syntax for it is a bit ugly so far though.