當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Model_Ad::getAdByName方法代碼示例

本文整理匯總了PHP中Model_Ad::getAdByName方法的典型用法代碼示例。如果您正苦於以下問題:PHP Model_Ad::getAdByName方法的具體用法?PHP Model_Ad::getAdByName怎麽用?PHP Model_Ad::getAdByName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Model_Ad的用法示例。


在下文中一共展示了Model_Ad::getAdByName方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: addAction

 /**
  * 添加推廣
  */
 public function addAction()
 {
     if ($this->isPost()) {
         $iAdID = (int) $this->getParam('id');
         $aAd = null;
         if ($iAdID > 0) {
             $aAd = Model_Ad::getDetail($iAdID);
             if ($aAd['iUserID'] != $this->aCurrUser['iUserID']) {
                 return $this->showMsg('不要亂改別人的數據', false);
             }
         }
         $aData = array();
         $aData['iUserID'] = $this->aCurrUser['iUserID'];
         $aData['iMediaType'] = (int) $this->getParam('iMediaType');
         $aData['iAdType'] = (int) $this->getParam('iAdType');
         $aData['sAdName'] = $this->getParam('sAdName');
         $aData['iPlanMinMoney'] = (int) $this->getParam('iPlanMinMoney');
         $aData['iPlanMaxMoney'] = (int) $this->getParam('iPlanMaxMoney');
         $aData['sCatID'] = (int) $this->getParam('sCatID');
         $aAdType = $this->getParam('aAdType');
         $aCityID = $this->getParam('aCityID');
         $aErr = array();
         if (!Util_Validate::isLength($aData['sAdName'], 2, 50)) {
             $aErr['sAdName'] = '請輸入推廣名稱';
         }
         if ($aData['iPlanMinMoney'] > $aData['iPlanMaxMoney']) {
             $aErr['iPlanMoney'] = '後者數字必須大於前者數字';
         }
         /*
          * if (empty($aAdType)) { $aErr['aAdType'] = '請選擇廣告類型'; } if (empty($aCatID)) { $aErr['aCatID'] = '請選擇媒體類別'; }
          */
         /*
          * if (empty($aCityID)) { $aErr['aCityID'] = '請選擇城市/地區'; }
          */
         if (!empty($aCityID) && count($aCityID) > 3) {
             $aErr['aCityID'] = '最多選擇3個城市/地區';
         }
         // 判斷該自媒是否已經存在
         if (!empty($aData['sAdName'])) {
             $aOtherAd = Model_Ad::getAdByName($aData['iUserID'], $aData['sAdName'], $iAdID);
             if (!empty($aOtherAd) && $aOtherAd['iStatus'] != Model_Ad::STATUS_DELETE) {
                 $aErr['sAdName'] = '該推廣計劃已經存在!';
             }
         }
         if (!empty($aErr)) {
             return $this->showMsg($aErr, false);
         }
         /*
          * if (count($aAdType) == 2) { $aData['iAdType'] = 3; } else { $aData['iAdType'] = array_pop($aAdType); }
          */
         $aData['sCityID'] = empty($aCityID) ? '' : join(',', $aCityID);
         $aData['iStatus'] = Model_Ad::STATUS_WRITING;
         if (empty($aAd)) {
             $iAdID = Model_Ad::addData($aData);
         } else {
             $aData['iAdID'] = $aAd['iAdID'];
             Model_Ad::updData($aData);
         }
         Model_User::updData(array('iUserID' => $this->aCurrUser['iUserID'], 'iFirst' => 'iFirst + 1'));
         if ($iAdID > 0) {
             return $this->showMsg($iAdID, true);
         } else {
             $aErr['sAdName'] = '添加失敗,請稍後再試';
             return $this->showMsg($aErr, false);
         }
     } else {
         $iAdID = intval($this->getParam('id'));
         $aAd = null;
         if ($iAdID > 0) {
             $aAd = Model_Ad::getDetail($iAdID);
         }
         if (empty($aAd)) {
             $iType = intval($this->getParam('type', Model_Media::TYPE_WEIXIN));
         } else {
             $iType = $aAd['iMediaType'];
             $aAd['aCityID'] = explode(',', $aAd['sCityID']);
             $aAd['aCatID'] = explode(',', $aAd['sCatID']);
         }
         $aData = array();
         switch ($iType) {
             case Model_Media::TYPE_WEIXIN:
                 $aData['aCategory'] = Model_Domain::getOption(Model_Domain::TYPE_MEDIA_WEIXIN_CATEGORY);
                 // $aData['aTag'] = Model_Domain::getOption(Model_Domain::TYPE_MEDIA_WEIXIN_TAG);
                 break;
             case Model_Media::TYPE_FRIEND:
                 $aData['aCategory'] = Model_Domain::getOption(Model_Domain::TYPE_MEDIA_FRIEND_CATEGORY);
                 // $aData['aTag'] = Model_Domain::getOption(Model_Domain::TYPE_MEDIA_FRIEND_TAG);
                 break;
             case Model_Media::TYPE_WEIBO:
                 $aData['aCategory'] = Model_Domain::getOption(Model_Domain::TYPE_MEDIA_WEIBO_CATEGORY);
                 // $aData['aTag'] = Model_Domain::getOption(Model_Domain::TYPE_MEDIA_WEIBO_TAG);
                 break;
             case Model_Media::TYPE_NEWS:
                 $aData['aCategory'] = Model_Domain::getOption(Model_Domain::TYPE_MEDIA_NEWS_CATEGORY);
                 // $aData['aTag'] = Model_Domain::getOption(Model_Domain::TYPE_MEDIA_NEWS_TAG);
                 break;
         }
//.........這裏部分代碼省略.........
開發者ID:pancke,項目名稱:yyaf,代碼行數:101,代碼來源:Ad.php


注:本文中的Model_Ad::getAdByName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。