#------------------------------------------------------------
# Copyright (C) 2006 RoyaltyShare, Inc.   All Rights Reserved
# $Id$
#------------------------------------------------------------
package RPS::DB::Item::ServiceFormatChannelMap;
use strict;
use warnings;
use lib '/app/tools/common/lib';
use Common::DB::Item;
use base 'Common::DB::Item';

use constant kAnyService => 0;
use constant kTable      => 'service_format_channel_map';
use constant kDB         => Common::DB::Item::kClientDB();

sub GetChannelIDByServiceAndFormat {
    my ( $class, $serviceID, $formatType ) = @_;

    my $dbo = Common::RSApp::GetClientDB();

    my $sql =
        "SELECT channel_id FROM service_format_channel_map"
      . " WHERE service_id=$serviceID"
      . " AND format_type="
      . $dbo->DBQuote($formatType);

    my $collection = $class->GetAll($sql);

    # return one or nothing
    #
    return ( $collection->hasNext() ) ? $collection->next() : undef;
}

1;
