当前位置: 首页>>代码示例>>PHP>>正文


PHP Ad::adWithAllFields方法代码示例

本文整理汇总了PHP中Ad::adWithAllFields方法的典型用法代码示例。如果您正苦于以下问题:PHP Ad::adWithAllFields方法的具体用法?PHP Ad::adWithAllFields怎么用?PHP Ad::adWithAllFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Ad的用法示例。


在下文中一共展示了Ad::adWithAllFields方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: pageController

function pageController($dbc)
{
    if (isset($_GET['ad-id'])) {
        $oneAd = Ad::adWithAllFields($_GET['ad-id']);
    } else {
        header("Location: ads.index.php");
        die;
    }
    $ad = $oneAd->getAttributes();
    $ad['keywords'] = implode(', ', $ad['keywords']);
    $ad['price'] = '$' . number_format($ad['price'], 2, '.', ',');
    $ad['date_posted'] = new DateTime($ad['date_posted']);
    $ad['date_posted'] = $ad['date_posted']->format('F d, Y');
    // var_dump($ad);
    return array('ad' => $ad);
}
开发者ID:adlister-project,项目名称:Craigslister,代码行数:16,代码来源:ads.show.php

示例2: pageController

function pageController($dbc)
{
    $errors = [];
    $keywords = [];
    $categoryResults = Ad::getAllCategories();
    foreach ($categoryResults as $category) {
        $categories[] = $category['category'];
    }
    if (Input::has('ad-id')) {
        $oneAd = Ad::adWithAllFields(Input::getNumber('ad-id'));
    } else {
        header("Location: ads.index.php");
        die;
    }
    $ad = $oneAd->getAttributes();
    $keyword = array_values($ad);
    var_dump('$_POST');
    var_dump($_POST);
    if (isset($_POST)) {
        try {
            $title = Input::getString('title');
        } catch (Exception $e) {
            array_push($errors, $e->getMessage());
        }
        try {
            $description = Input::getString('description');
        } catch (Exception $e) {
            array_push($errors, $e->getMessage());
        }
        try {
            $price = Input::getNumber('price');
        } catch (Exception $e) {
            array_push($errors, $e->getMessage());
        }
        try {
            $keyword_1 = Input::getString('keyword_1');
        } catch (Exception $e) {
            array_push($errors, $e->getMessage());
        }
        try {
            $keyword_2 = Input::getString('keyword_2');
        } catch (Exception $e) {
            array_push($errors, $e->getMessage());
        }
        try {
            $keyword_3 = Input::getString('keyword_3');
        } catch (Exception $e) {
            array_push($errors, $e->getMessage());
        }
    }
    if (isset($_POST['keyword_1'])) {
        $keywords[0] = $_POST['keyword_1'];
    } else {
        if (isset($keyword[7][1])) {
            $keywords[0] = $keyword[7][1];
        } else {
            $keywords[0] = '';
        }
    }
    if (isset($_POST['keyword_2'])) {
        $keywords[1] = $_POST['keyword_2'];
    } else {
        if (isset($keyword[7][2])) {
            $keywords[1] = $keyword[7][2];
        } else {
            $keywords[1] = '';
        }
    }
    if (isset($_POST['keyword_3'])) {
        $keywords[2] = $_POST['keyword_3'];
    } else {
        if (isset($keyword[7][3])) {
            $keywords[2] = $keyword[7][3];
        } else {
            $keywords[2] = '';
        }
    }
    var_dump('$ad');
    var_dump($ad);
    var_dump('$errors');
    var_dump($errors);
    if (empty($errors)) {
        try {
            Ad::updateAds(Input::getNumber('ad-id'), $title, $description, $price);
            Keyword::updateKeywords(Input::getNumber('ad-id'), $keywords[0], $keywords[1], $keywords[2]);
            var_dump($keywords);
        } catch (Exception $e) {
            echo 'Error';
            // $_SESSION
        }
    }
    return array('ad' => $ad, 'categories' => $categories, 'keywords' => $keywords, 'errors' => $errors);
}
开发者ID:adlister-project,项目名称:Craigslister,代码行数:93,代码来源:ads.edit.php


注:本文中的Ad::adWithAllFields方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。