function get_subjects($con, $args)
{
    $subjects = array();
    if (isset($args["sid"])) {
        $sid = $args["sid"];
        $sql = $con->prepare("SELECT sname,`order` FROM subject WHERE sid=?");
        $sql->bind_param("i", $sid);
        $sql->bind_result($sname, $order);
        $sql->execute();
        $sql->fetch();
        $sql->close();
        if (isset($sname) && isset($order)) {
            $tmp = new Subject();
            $tmp->populate($sid, $sname, [], $order);
            $subjects[] = $tmp->expose();
        }
    } else {
        if (isset($args["sname"])) {
            $sname = $args["sname"];
            $sql = $con->prepare("SELECT sid,`order` FROM subject WHERE sname=?");
            $sql->bind_param("s", $sname);
            $sql->bind_result($sid, $order);
            $sql->execute();
            $sql->fetch();
            $sql->close();
            if (isset($sid) && isset($order)) {
                $tmp = new Subject();
                $tmp->populate($sid, $sname, [], $order);
                $subjects[] = $tmp->expose();
            }
        } else {
            $sql = $con->prepare("SELECT sid,sname,`order` FROM subject ORDER BY `order` ASC");
            $sql->bind_result($sid, $sname, $order);
            $sql->execute();
            while ($sql->fetch()) {
                if (isset($sid) && isset($sname) && isset($order)) {
                    $tmp = new Subject();
                    $tmp->populate($sid, $sname, [], $order);
                    $subjects[] = $tmp->expose();
                }
            }
            $sql->close();
        }
    }
    return $subjects;
}