Hi,
Using Catalyst and DBIC
Being quite new to DBIC class I really struggle with the syntax but getting
closer.
I have a table named authorized_users with 3 fields: id,email,policy
a policy has many users and a user has many policies.
I would like to delete a subset of users for a given policy
The users to be deleted are in array $diff->deleted
I construct the following:
if( @{$diff->deleted} ) {
my $del_list;
foreach my $val (@{$diff->deleted}) { $del_list .= "$val,";}
my $result_set =
$c->model('DLDB::Model::CatalystModelName::AuthorizedUsers')
->search({
-and => [
{'policy' => $data->{policy}},
{'email' => "IN($del_list)" }
]
} )->delete;
}
Lets say my input is policy='policy1' and $diff->deleted contains 2 users
'[EMAIL PROTECTED], [EMAIL PROTECTED]'
Outputting SQL with DBIC_TRACE set shows:
DELETE FROM authorized_users WHERE ( ( ( policy = ? ) AND ( email = ? ) ) ):
'policy1', 'IN([EMAIL PROTECTED],[EMAIL PROTECTED] )'
but this does not delete the users as expected.
I'm probably doing this wrong trying to bend DBIC class towards my way of SQL
thinking.
So please clear my mind and tell me what to do or what I'm doing wrong?
regards and thanks
Peter Sorensen/University of Southern Denmark/email: [EMAIL PROTECTED]
_______________________________________________
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/[EMAIL PROTECTED]