Advertisement
lemb

Untitled

Aug 25th, 2012
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.45 KB | None | 0 0
  1. $query = 'select
  2. id, user_id, campaign_id, image, text, price,
  3. case
  4. when teaserstat.view <=> null then 0
  5. when teaserstat.view >= 0 and teaserstat.view <= 5000 and teaserstat.click = 0 then 1
  6. when teaserstat.click > 0 then 2
  7. when teaserstat.view > 5000 then 2
  8. end as firstord,
  9. case
  10. when teaserstat.view is not null and teaserstat.click = 0 then (0.01 * price)
  11. when teaserstat.view is not null then ((teaserstat.ctr * teaserstat.ctr) * price)
  12. end as secondord
  13. from '.$var['base_tab_prefix'].'teasers left join (
  14. select teaser_id, view, click, ((100/view)*click) as ctr
  15. from adtram_teasers_stat
  16. where dataadd = "'.$var['date'].'"
  17. ) as teaserstat
  18. on adtram_teasers.id = teaserstat.teaser_id
  19. where status="2"
  20. and ban_site not like "%'.$referer_url.'%"
  21. '.($site[0]['ban_teaser'] != '' ? 'and id not in ('.$site[0]['ban_teaser'].')' : '').'
  22. '.($good_users_ids != '' ? 'and user_id in ('.$good_users_ids.')' : 'and user_id = "bla-bla"').'
  23. '.($ban_sections_ids ? 'and section_id not in ('.$ban_sections_ids.')' : '').'
  24. '.($ipgeobase['region'] != '' ? 'and ban_region not like "%~'.$ipgeobase['region'].'~%"' : '').'
  25. '.($ipgeobase['country'] != '' ? 'and ban_country not like "%~'.$ipgeobase['country'].'~%"' : '').'
  26. and ban_hour not like "%~'.date("G", strtotime($var['datetime'])).'~%"
  27. and ban_week_day not like "%~'.date("w", strtotime($var['datetime'])).'~%"
  28. and url not like "%'.$referer_url.'%"
  29. order by firstord asc, secondord desc, last_show asc
  30. limit '.$mlimit;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement