function addCandidateToCollege($college, $candidate, $party, $source) { if ($candidate == "") { return; } $context = "+ {{$college}} ({$party}) {$candidate}"; info($context); $results = getPersonsByName($candidate, $context, infoFunction); if (count($results) == 0) { $person = addPersonToDatabase($candidate, $candidate); } else { $person = $results[0]; info(" - person {{$candidate}} id : [" . $person->id . "]"); // Make sure this matches! $s = mysql_query("\n SELECT colegiu, partid\n FROM results_2012_old\n WHERE idperson = {$person->id}"); $r = mysql_fetch_array($s); if ($r) { $current_college = ucwords(strtolower(str_replace("-", " ", $r["colegiu"]))); $exclude_ids = array(1134, 77, 777, 4646, 1676, 3957, 3961, 4512, 2285, 2213, 277, 2220, 2228, 4411, 4407, 4401, 4403, 4750, 4744, 2344, 4409, 1208, 4405, 4405, 2341, 3145, 4473, 4464, 125, 3655, 3658, 3793, 4074, 4415, 4609, 2134, 176, 2207, 4398, 2244, 3888, 4541, 3897, 3901, 3905); if ($current_college != "" && $current_college != $college && !in_array($person->id, $exclude_ids)) { info("We might have a problem. [{$current_college}] != [{$college}]"); die; } $party = $r["partid"]; } } $partyId = getPartyId($party); if ($partyId <= 0) { die("party id gone wrong {$party} {$partyId}"); } // Now that I have the person, let's populate the database with it. // We need two things: One an entry in results_2012, and an entry in // people_history so we can display the mod on their own page. mysql_query("\n INSERT INTO results_2012(nume, idperson, partid, idpartid, colegiu)\n values('{$candidate}', {$person->id}, '{$party}', {$partyId}, '{$college}')\n "); mysql_query("\n INSERT INTO people_history(idperson, what, url, time)\n values({$person->id}, 'results/2012', '{$source}', 1355032800)\n "); }
function addCandidateToCollege($college, $candidate, $party) { if ($candidate == "") { return; } $context = "+ {{$college}} ({$party}) {$candidate}"; info($context); $results = getPersonsByName($candidate, $context, infoFunction); if (count($results) == 0) { $person = addPersonToDatabase($candidate, $candidate); } else { $person = $results[0]; info(" - person {{$candidate}} id : [" . $person->id . "]"); } $partyId = getPartyId($party); if ($partyId <= 0) { die('party id gone wrong'); } // Now that I have the person, let's populate the database with it. // We need two things: One an entry in results_2012, and an entry in // people_history so we can display the mod on their own page. mysql_query("\n INSERT INTO results_2012(nume, idperson, partid, idpartid, colegiu)\n values('{$candidate}', {$person->id}, '{$party}', {$partyId}, '{$college}')\n "); mysql_query("\n INSERT INTO people_history(idperson, what, url, time)\n values({$person->id}, 'results/2012', 'http://goo.gl/64gsf', 1355032800)\n "); }