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; }
/** * 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; }
public function redirect() { $ad = Advertisement::find($this->params()->id); $ad->increment('hit_count'); $this->redirectTo($ad->referral_url); }
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); }