diff --git a/scripts/clean_thesaurus_without_authorities.php b/scripts/clean_thesaurus_without_authorities.php index aa109171da05115bda934dbb25ae0e0ba558d9fc..1b804fecddd39dc0919f09f67a2ba89501777ae0 100644 --- a/scripts/clean_thesaurus_without_authorities.php +++ b/scripts/clean_thesaurus_without_authorities.php @@ -21,7 +21,8 @@ Class Script_Thesaurus_Cleaner { use Trait_MemoryCleaner; protected $without_authorities, $not_found_matching = [], - $patch; + $patch, + $_replaced='facettes'; public function __construct () { $this->patch = fopen("/tmp/patch_update_thesaurus.php", "w") or die("Unable to open file!"); } @@ -41,7 +42,11 @@ Class Script_Thesaurus_Cleaner { return (!Class_Exemplaire::findFirstAuthorityItemByOriginId($codif->getIdOrigine())); }); } - + public function writeUpdate() { + $sql= "UPDATE notices SET facettes = ".$this->_replaced .";"; + fwrite($this->patch, $sql."\n"); + $this->_replaced='facettes'; + } public function deleteFacetInNotice($codif,$matching) { return $this->changeFacetInNotice($codif->getIdThesaurus(), $codif->getFacetteIndex(),$matching); @@ -54,10 +59,7 @@ Class Script_Thesaurus_Cleaner { $replace_facet=""; if ($replace_facet = $matching[$facet_id]) $replace_facet = 'H'.$replace_facet; - - $sql = "UPDATE notices SET facettes = REPLACE(facettes,'".$facet_index."','".$replace_facet."') where facettes like '%".$facet_index."%';"; - fwrite($this->patch, $sql."\n"); -// sqlExecute($sql); + $this->_replaced = "REPLACE(".$this->_replaced.",'".$facet_index."','".$replace_facet."')" ; } @@ -171,13 +173,17 @@ foreach($without_authorities as $codif) { $script->replaceBookmarks($matching); $script->replaceDomains($matching); echo 'Update Facettes in notices'."\n"; - +$count = 0; foreach($without_authorities as $codif) { $script->deleteFacetInNotice($codif, $matching); $codif->deleteMeAndMyChildren(); -} + if ($count%300 == 0) + $script->writeUpdate(); + $count++; +} +$script->writeUpdate(); /*foreach ($force_matching as $key => $match) { $script->changeFacetInNotice($key, 'H'.$key,$force_matching); }*/