4 # Copyright 2000-2002 Katipo Communications
6 # This file is part of Koha.
8 # Koha is free software; you can redistribute it and/or modify it under the
9 # terms of the GNU General Public License as published by the Free Software
10 # Foundation; either version 2 of the License, or (at your option) any later
13 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License along with
18 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
19 # Suite 330, Boston, MA 02111-1307 USA
22 # This script generates and fill the thesaurus table
23 # with the data in bibliothesaurus
34 my ($dbh,$sql_cmd)=@_;
35 my $sti=$dbh->prepare($sql_cmd);
38 print "error : ".$sti->errstr." \n tried to execute : $sql_cmd\n";
43 my $sth=$dbh->prepare("show tables");
46 while (my ($table) = $sth->fetchrow) {
48 # print "table $table\n";
51 print "creating thesaurus...\n";
52 dosql($dbh,"CREATE TABLE bibliothesaurus (code BIGINT not null AUTO_INCREMENT, freelib CHAR (255) not null , stdlib CHAR (255) not null , type CHAR (80) not null , PRIMARY KEY (code), INDEX (freelib),index(stdlib),index(type))");
53 my $sti=$dbh->prepare("select count(*) as tot from bibliosubject");
55 my $total = $sti->fetchrow_hashref;
56 my $sti=$dbh->prepare("select subject from bibliosubject");
59 while (my $line =$sti->fetchrow_hashref) {
62 print "$i / $total->{'tot'}\n";
64 # print "$i $line->{'subject'}\n";
65 my $sti2=$dbh->prepare("select count(*) as t from bibliothesaurus where freelib=".$dbh->quote($line->{'subject'}));
68 print "error : ".$sti2->errstr."\n";
71 my $line2=$sti2->fetchrow_hashref;
72 if ($line2->{'t'} ==0) {
73 dosql($dbh,"insert into bibliothesaurus (freelib,stdlib) values (".$dbh->quote($line->{'subject'}).",".$dbh->quote($line->{'subject'}).")");
75 # print "pas ecriture pour : $line->{'subject'}\n";