Пример #1
0
    public function option($name, $type)
    {
        global $db;
        $res = $db->selectCol("SELECT id_{$name} AS ARRAY_KEY, {$name}_name FROM " . $type);
        return $res;
    }
}
if ($_SERVER['REQUEST_METHOD'] == 'POST' && empty($_GET['id'])) {
    if ($_POST['id_type'] == 1) {
        $ad = new PrivatePersonAds($_POST);
        $ad->save();
    } else {
        $ad = new CompanyAds($_POST);
        $ad->save();
    }
} elseif (isset($_GET['action']) && $_GET['action'] == 'delete') {
    $ad = new Ads($_POST);
    $ad->delete();
} elseif ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['change'])) {
    $_POST['ad_id'] = $_GET['id'];
    $change = new Ads($_POST);
    $change->save();
    header("Location: HW15.php?id={$_GET['id']}");
} elseif (isset($_GET['id'])) {
    $full = new Ads($_POST);
    $smarty->assign('selected_ads', $full->fullAd());
}
$main = AdsStore::instance();
$main->getAllAdsFromDb();
$main->writeOut();
$smarty->display('HW15.tpl');