コード例 #1
2
ファイル: advertise.php プロジェクト: vsanth/propertykon
 function GetAdvertisementList($type = 'developer', $limit = 10, $orderBY = null, $OrderType = 'ASC')
 {
     App::import('Model', 'Advertisement');
     $objAdvertisement = new Advertisement();
     $this->Advertisement->recursive = -1;
     if ($orderBY != null) {
         $orderValue = array("Advertisement.{$orderBY}" => $OrderType);
     } else {
         $orderValue = 'RAND()';
     }
     $arrData = $objAdvertisement->find("all", array("conditions" => array("Advertisement.gallery_type " => $type, 'Advertisement.active' => 'Y'), 'order' => $orderValue, 'limit' => $limit));
     return $arrData;
 }
コード例 #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Advertisement::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'id_user' => $this->id_user, 'date' => $this->date, 'id_category' => $this->id_category]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'text', $this->text]);
     return $dataProvider;
 }
コード例 #3
0
 public function redirect()
 {
     $ad = Advertisement::find($this->params()->id);
     $ad->increment('hit_count');
     $this->redirectTo($ad->referral_url);
 }
コード例 #4
0
 public function delAd($id)
 {
     DB::beginTransaction();
     try {
         $ad = Advertisement::find($id);
         $ad->delAd();
         $re = Tools::reTrue('删除成功');
         DB::commit();
     } catch (Exception $e) {
         $re = Tools::reFalse($e->getCode(), '删除失败:' . $e->getMessage());
         DB::rollback();
     }
     return Response::json($re);
 }