$d = OppSimilaritaPeer::retrieveByPK($politici[$i]['id'], $politici[$j]['id']); if (is_null($d)) { $d = new OppSimilarita(); $d->setCaricaFromId($politici[$i]['id']); $d->setCaricaToId($politici[$j]['id']); } $d->setVotingSimilarity(OppSimilaritaPeer::similarityForVotes($politici[$i], $politici[$j], $ramo) / $ncariche); $d->save(); // scrittura elemento simmetrico $ds = OppSimilaritaPeer::retrieveByPK($politici[$j]['id'], $politici[$i]['id']); if (is_null($ds)) { $ds = new OppSimilarita(); $ds->setCaricaFromId($d->getCaricaToId()); $ds->setCaricaToId($d->getCaricaFromId()); } $ds->setVotingSimilarity($d->getVotingSimilarity()); $ds->save(); $ds = null; unset($ds); $d = null; unset($d); } print "."; if ($i > 0 && $i % 10 == 0) { print "{$i}/{$ncariche} "; } if ($i > 0 && $i % 50 == 0) { print "\n"; } } echo "done\n";