本文整理汇总了PHP中Model_Ad::addData方法的典型用法代码示例。如果您正苦于以下问题:PHP Model_Ad::addData方法的具体用法?PHP Model_Ad::addData怎么用?PHP Model_Ad::addData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model_Ad
的用法示例。
在下文中一共展示了Model_Ad::addData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addAction
/**
* 增加广告
*/
public function addAction()
{
if ($this->_request->isPost()) {
$aAd = $this->_checkData('add');
if (empty($aAd)) {
return null;
}
if (Model_Ad::addData($aAd) > 0) {
return $this->showMsg('广告增加成功!', true);
} else {
return $this->showMsg('广告增加失败!', false);
}
}
}
示例2: 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;
}
//.........这里部分代码省略.........