DBIx::Classで検索方法色々
今更ながらにDBIx::Classを使ってみた。
その時に勉強した検索方法色々。
# IDを指定して検索 $db->resultset('table')->find(ID); # 条件を指定して検索 $db->resultset('table')->search({ flg => 1, }); # and検索 $db->resultset('table')->search({ flg => 1, id => 2, }); # or検索 $db->resultset('table')->search({ -or => [ flg => 1, id => 2, ] }); # andとorの組み合わせ $db->resultset('table')->search({ -or => [ { flg => 1, id => 2, }, flg => 2, ] }); # 不等号とか $db->resultset('table')->search({ id => {'>' => 3}, }); # order byとか $db->resultset('table')->search({ flg => 1, }, {order_by => 'id'});