Skip to content

Instantly share code, notes, and snippets.

@rtgibbons
Created September 23, 2013 02:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rtgibbons/6665747 to your computer and use it in GitHub Desktop.
Save rtgibbons/6665747 to your computer and use it in GitHub Desktop.
custom impact mysql error
public function getTotalDonationImpactOfUserIds($user_ids_array){
$queryGZ = "SELECT SUM(amount) FROM gz_donations where ";
$queryMGF = "SELECT SUM(amount) FROM mgf_donations where ";
for ($i=0; $i<count($user_ids_array); $i++){
$id = $this->db->escape($user_ids_array[$i]);
if ($i == count($user_ids_array) - 1) {
$queryGZ = $queryGZ . "referrer_user_id ='$id' OR donated_by_user_id ='$id'";
$queryMGF = $queryMGF . "referrer_user_id ='$id' OR donated_by_user_id ='$id'";
} else {
$queryGZ = $queryGZ . "referrer_user_id ='$id' OR donated_by_user_id ='$id' OR ";
$queryMGF = $queryMGF . "referrer_user_id ='$id' OR donated_by_user_id ='$id' OR ";
}
}
$resultsGZ = $this->db->query($queryGZ);
$rowGZ = mysql_fetch_assoc($resultsGZ);
$sumGZ = $rowGZ['SUM(amount)'];
//CPBLog::debug("GZ sum: " . $sumGZ);
$resultsMGF = $this->db->query($queryMGF);
$rowMGF = mysql_fetch_assoc($resultsMGF);
$sumMGF = $rowMGF['SUM(amount)'];
//CPBLog::debug("MGF sum: " . $sumMGF);
return $sumMGF + $sumGZ;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment