Skip to content

Instantly share code, notes, and snippets.

@pcave
Last active October 26, 2017 20:41
Show Gist options
  • Save pcave/18a79c5b1051daae194d8278ab308b73 to your computer and use it in GitHub Desktop.
Save pcave/18a79c5b1051daae194d8278ab308b73 to your computer and use it in GitHub Desktop.
Update card_id where missing
<?php
$result = db_query("SELECT f.did FROM fundraiser_sustainers_series s
INNER JOIN fundraiser_sustainers f ON f.master_did = s.did
INNER JOIN fundraiser_donation d ON d.did = f.did
WHERE s.status = 'active'
AND gateway = 'authnet_aim|commerce_payment_authnet_aim'
AND card_id IS NULL
AND d.status = 'pending_future_payment' limit 100");
foreach ($result as $record) {
$donation = fundraiser_donation_get_donation($record->did);
if (!empty($donation->data['cardonfile'])) {
// Save the card_id to the fundraiser_donation table for easier access.
db_query('UPDATE {fundraiser_donation} SET card_id = :card_id WHERE did = :did', array(
':card_id' => $donation->data['cardonfile'],
':did' => $record->did,
));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment