/**
 * just for recalculate all points in powerTrail_caches if any problem occur
 * or points algo were changed.
 */
function recalculateOnce()
{
    $allCachesQuery = 'SELECT * FROM `caches` where `cache_id` IN (SELECT `cacheId` FROM `powerTrail_caches` WHERE 1)';
    $db = \lib\Database\DataBaseSingleton::Instance();
    $db->multiVariableQuery($allCachesQuery);
    $allCaches = $db->dbResultFetchAll();
    foreach ($allCaches as $cache) {
        $cachePoints = powerTrailBase::getCachePoints($cache);
        $updateQuery = 'UPDATE `powerTrail_caches` SET `points`=:1 WHERE `cacheId`=:2';
        $db->multiVariableQuery($updateQuery, $cachePoints, $cache['cache_id']);
        print $cache['wp_oc'] . ' updated ' . $cachePoints . '<br/>';
    }
    // print '<pre>';
    // print_r($allCaches);
}
Ejemplo n.º 2
0
/**
 * just for recalculate all points in powerTrail_caches if any problem occur
 * or points algo were changed.
 */
function recalculateOnce()
{
    $db = OcDb::instance();
    $stmt = $db->multiVariableQuery('SELECT * FROM `caches` where `cache_id` IN (SELECT `cacheId` FROM `powerTrail_caches` WHERE 1)');
    $allCaches = $db->dbResultFetchAll($stmt);
    foreach ($allCaches as $cache) {
        $cachePoints = powerTrailBase::getCachePoints($cache);
        $db->multiVariableQuery('UPDATE `powerTrail_caches` SET `points`=:1 WHERE `cacheId`=:2', $cachePoints, $cache['cache_id']);
        print $cache['wp_oc'] . ' updated ' . $cachePoints . '<br/>';
    }
}