Exemple #1
0
function update_counts($table, $method_name, $condition)
{
    global $db;
    $new = $db->query("SELECT DISTINCT supporter_KEY FROM " . $table . " WHERE " . $condition);
    if ($new->num_rows > 0) {
        while ($new_arr = $new->fetch_assoc()) {
            $supporter_info = $db->query("SELECT * FROM supporter WHERE supporter_KEY=" . $new_arr['supporter_KEY'])->fetch_assoc();
            $supporter = new Supporter($supporter_info);
            $supporter->{$method_name}();
            $supporter->db_update();
            $supporter->data['key'] = $supporter->data['supporter_KEY'];
            //$dia->save('supporter', $supporter->data);
        }
    }
}
#trigger_error(print_r($supporter_KEY,TRUE));
$sql = "SELECT * FROM supporter WHERE supporter_KEY=" . $supporter_KEY;
$S = $db->Execute($sql) or die($db->errorMsg() . $sql);
$s = $S->GetAssoc();
$x = 0;
foreach ($s as $supporter_arr) {
    $supporter = new Supporter($supporter_arr);
    #$supporter->process_data_augmentation();
    # $supporter->geovalidate();
    if ($supporter_arr['source_processed'] != 1) {
        $supporter->process_source();
    }
    $supporter->updateDonationCounts();
    $supporter->updateActionCounts();
    $supporter->updateEmailCounts();
    $supporter->updateUnsubscribeInfo();
    $supporter->updateSupporterTypes();
    #update local
    $supporter->db_update();
    #save to salsa
    $data = $supporter->data;
    $data['key'] = $supporter_arr['supporter_KEY'];
    unset($data['organization_KEY']);
    #$out = $DIA->save('supporter',$data);
    # echo '<pre>';
    # print_r($data);
    # echo '</pre>';
    $x++;
    echo 'completed' . '
';
}