nsbm
nsbm

Reputation: 6152

Searching using a list of IDs in DBIx::Class

I have a list with IDs that are selected by the user. What is the best way to search all rows using this list of IDs in DBIx::Class??

Upvotes: 3

Views: 991

Answers (1)

hobbs
hobbs

Reputation: 240531

Use

$rs->search({ 
    whatever_the_column_is => { 
        '=' => [ @a_bunch_of_ids ]
    }
})

or

$rs->search({
    whatever_the_column_is => {
       -in => [ @a_bunch_of_ids ]
    }
})

if your DB likes IN queries better. Both are documented in SQL::Abstract docs.

Upvotes: 5

Related Questions