%PDF- %PDF-
Direktori : /home/nailstv/public_html/ |
Current File : /home/nailstv/public_html/__aggragateViews.php |
<?php /** * Created by PhpStorm. * User: ftamas88 * Date: 2015.06.23. * Time: 11:29 */ require_once 'config/config.php'; $db = Db::getInstance(); $start = microtime(true); $views = $db->GetAssoc(' SELECT video_id,COUNT(video_id) FROM video_nezettseg WHERE id BETWEEN ? AND ? GROUP BY video_id', array(0,25000020) ); /* $views = $db->GetAssoc(' SELECT video_id,COUNT(video_id) FROM video_nezettseg WHERE video_id IN (476,374,371,382) GROUP BY video_id' ); */ $heti = $db->GetAssoc(' select `video_nezettseg`.`video_id`,count(`video_nezettseg`.`video_id`) AS `nezettseg` from `video_nezettseg` where (`video_nezettseg`.`datum` > (now() - interval 1 week)) group by `video_nezettseg`.`video_id` order by count(`video_nezettseg`.`id`) desc '); $havi = $db->GetAssoc(' select `video_nezettseg`.`video_id`,count(`video_nezettseg`.`video_id`) AS `nezettseg` from `video_nezettseg` where (`video_nezettseg`.`datum` > (now() - interval 1 MONTH)) group by `video_nezettseg`.`video_id` order by count(`video_nezettseg`.`id`) desc '); $napi = $db->GetAssoc(' select `video_nezettseg`.`video_id`,count(`video_nezettseg`.`video_id`) AS `nezettseg` from `video_nezettseg` where (`video_nezettseg`.`datum` > (now() - interval 1 DAY)) group by `video_nezettseg`.`video_id` order by count(`video_nezettseg`.`id`) desc '); foreach( $views as $id => $osszes_nezettseg ) { $db->update(compact('id','osszes_nezettseg'),'video'); } foreach( $heti as $id => $heti_nezettseg) { $db->update(compact('id','heti_nezettseg'),'video'); } foreach( $havi as $id => $havi_nezettseg) { $db->update(compact('id','havi_nezettseg'),'video'); } foreach( $napi as $id => $napi_nezettseg) { $db->update(compact('id','napi_nezettseg'),'video'); } $end = round((microtime(true) - $start),4).'s'; echo '<pre>----------<br />'; echo $end; die();