[Dbix-class] search using multiple values for the same column
Fernan Aguero
fernan at iib.unsam.edu.ar
Wed Jul 5 17:07:46 CEST 2006
Hi,
I'm having trouble with this:
TABLE items (item_id, item)
TABLE features (feature_id, feature)
TABLE item_features (item_id, feature_id)
the latter being a join/linking table, so that any item can
have many features and any feature can be related to many
items.
then I do something like this:
my $dbix = My::Schema->connect( ... );
my $item = $dbix->resultset('Items');
my $feat = $dbix->resultset('Features');
my $itfeat = $dbix->resultset('ItemFeatures');
my $itemrs = $item->search( { item_id => $item_id } );
my $itemfeatrs = $itfeat->search( { item_id => $item_id } );
# now I want to get all feature data for the feature_ids I
# obtained in the last query
my $features = [];
while (my $itemfeature = $itemfeatrs->next() ) {
push @{$features}, $itemfeature->feature_id;
}
# and now I should do the following
my $featrs = $feat->search( { feature_id => $features } );
except that the problem is before this step, because
$itemfeature->feature_id
is not returning a scalar (the id) but a HASH
All classes were generated by Schema::Loader
(relationships => 1)
DBIx-Class-0.06003
DBIx-Class-Schema-Loader-0.03003
Is this a bug? Am I doing something wrong?
Thanks in advance,
Fernan
More information about the Dbix-class
mailing list