Ejemplo n.º 1
0
function copyDailyDataAndReset()
{
    $db = db();
    error_log('copy daily data');
    $db->beginTransaction();
    $db->prepare('
		insert into monthlyresults_google
			select null as id, project, pos, keyword, NOW() as checkdate
				from results_google
	')->execute();
    $db->prepare('update results_google
		set posprev = pos, process = 0')->execute();
    $db->prepare('
		insert into monthlyresults_mail
			select null as id, project, pos, keyword, NOW() as checkdate
				from results_mail
	')->execute();
    $db->prepare('update results_mail
		set posprev = pos, process = 0')->execute();
    $db->prepare('
		insert into monthlyresults_yandex
			select null as id, project, pos, keyword, region_code, region_name, NOW() as checkdate
				from results_yandex
	')->execute();
    $db->prepare('update results_yandex
		set posprev = pos, process = 0')->execute();
    $db->commit();
    updateProjectsKeywords();
    error_log('resets num = 0');
    setResetsNum(0);
    error_log(getResetsNum());
}
Ejemplo n.º 2
0
function resetErrorKeywordsPos($type)
{
    $db = db();
    //error_log('no data for processing ' . $type);
    $numResets = getResetsNum();
    if ($numResets < 2) {
        // limit resets errors keywords pos
        error_log('reset errors keywords pos - ' . $numResets);
        $db->prepare('update results_' . $type . '
			set pos = greatest(posprev, 0), process = 0
			where process = 1 and pos < 0')->execute();
        setResetsNum($numResets + 1);
    }
}