Файл: adultscript-2.0.3-pro/files/modules/video/scripts/categorize.php
Строк: 18
<?php
define('_VALID', TRUE);
define('_CONSOLE', TRUE);
if (php_sapi_name() != 'cli') {
die('This script can be called from the console only!');
}
set_time_limit(0);
$base_dir = realpath(dirname(__FILE__).'/../../../');
require $base_dir.'/libraries/bootstrap.php';
VHelper::load('module.video.category');
$db = VF::factory('database');
$db->query("SELECT cat_id, auto_term
FROM #__video_categories
ORDER BY name ASC");
$categories = $db->fetch_rows();
$sql_count = "SELECT COUNT(*) AS total_videos
FROM #__video
WHERE status = 1";
$total_videos = $db->get_field($sql_count, 'total_videos');
$sql = "SELECT v.video_id, v.title, v.description
GROUP_CONCAT(DISTINCT c.cat_id) AS categories,
GROUP_CONCAT(DISTINCT t.name) AS tags
FROM #__video AS v
INNER JOIN #__video_category AS c ON (c.video_id = v.video_id)
INNER JOIN #__video_tags AS t ON (t.video_id = v.video_id)
WHERE v.status = 1
GROUP BY v.video_id
ORDER BY video_id ASC";
$start = 0;
$amount = 1000;
while ($start <= $total_videos) {
$videos = $db->get_rows($sql.' LIMIT '.$start.', '.$amount);
$start = ($start+$amount);
foreach ($videos as $video) {
VHelper_video_category::categorize(
(int) $video['video_id'], $video['title'], $video['description'],
$video['categories'], $video['tags'], $categories
);
}
}
VF::close();
?>