<?php
    require_once 'Campana.php';
    require_once 'ClienteDatos.php';
    class CampanaDatos{
        public static function getCampanaById(string $id):?Campana{
            $resp = null;
            $con = getConnection();
            $query = "SELECT user_group, campaign_name, campaign_id FROM vicidial_campaigns WHERE campaign_id = '".limpia($id)."' LIMIT 1";
            if($result = sv_mysqli_query($con,$query)){
                if($row = sv_mysqli_fetch_array($result)){
                    $resp = new Campana($row["campaign_id"],ClienteDatos::getClienteById($row["user_group"]),$row["campaign_name"]);
                }
            }
            return $resp;
        }
    }
?>