Fix for bug 920. The problem was that getMARCnotes had the variable set to be the...
[koha.git] / C4 / SearchMarc.pm
1 package C4::SearchMarc;
2
3 # Copyright 2000-2002 Katipo Communications
4 #
5 # This file is part of Koha.
6 #
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
10 # version.
11 #
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License along with
17 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18 # Suite 330, Boston, MA  02111-1307 USA
19
20 use strict;
21 require Exporter;
22 use DBI;
23 use C4::Context;
24 use C4::Biblio;
25 use C4::Date;
26 use Date::Manip;
27
28 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
29
30 # set the version for version checking
31 $VERSION = 0.02;
32
33 =head1 NAME
34
35 C4::Search - Functions for searching the Koha MARC catalog
36
37 =head1 FUNCTIONS
38
39 This module provides the searching facilities for the Koha MARC catalog
40
41 =cut
42
43 @ISA = qw(Exporter);
44 @EXPORT = qw(&catalogsearch &findseealso &findsuggestion &getMARCnotes &getMARCsubjects);
45
46 =head1 findsuggestion($dbh,$values);
47
48 =head2 $dbh is a link to the DB handler.
49
50 use C4::Context;
51 my $dbh =C4::Context->dbh;
52
53 =head2 $values is a word
54
55 Searches words with the same soundex, ordered by frequency of use.
56 Useful to suggest other searches to the users.
57
58 =cut
59
60 sub findsuggestion {
61         my ($dbh,$values) = @_;
62         my $sth = $dbh->prepare("SELECT count( * ) AS total, word FROM marc_word WHERE sndx_word = soundex( ? ) AND word <> ? GROUP BY word ORDER BY total DESC");
63         my @results;
64         for(my $i = 0 ; $i <= $#{$values} ; $i++) {
65                 if (length(@$values[$i]) >=5) {
66                         $sth->execute(@$values[$i],@$values[$i]);
67                         my $resfound = 1;
68                         my @resline;
69                         while ((my ($count,$word) = $sth->fetchrow) and $resfound <=10) {
70                                 push @results, "@$values[$i]|$word|$count";
71 #                               $results{@$values[$i]} = \@resline;
72                                 $resfound++;
73                         }
74                 }
75         }
76         return \@results;
77 }
78
79 =head1 findseealso($dbh,$fields);
80
81 =head2 $dbh is a link to the DB handler.
82
83 use C4::Context;
84 my $dbh =C4::Context->dbh;
85
86 =head2 $fields is a reference to the fields array
87
88 This function modify the @$fields array and add related fields to search on.
89
90 =cut
91
92 sub findseealso {
93         my ($dbh, $fields) = @_;
94         my $tagslib = MARCgettagslib ($dbh,1);
95         for (my $i=0;$i<=$#{$fields};$i++) {
96                 my ($tag) =substr(@$fields[$i],1,3);
97                 my ($subfield) =substr(@$fields[$i],4,1);
98                 @$fields[$i].=','.$tagslib->{$tag}->{$subfield}->{seealso} if ($tagslib->{$tag}->{$subfield}->{seealso});
99         }
100 }
101
102 =head1  my ($count, @results) = catalogsearch($dbh, $tags, $and_or, $excluding, $operator, $value, $offset,$length,$orderby);
103
104 =head2 $dbh is a link to the DB handler.
105
106 use C4::Context;
107 my $dbh =C4::Context->dbh;
108
109 $tags,$and_or, $excluding, $operator, $value are references to array
110
111 =head2 $tags
112
113 contains the list of tags+subfields (for example : $@tags[0] = '200a')
114 A field can be a list of fields : '200f','700a','700b','701a','701b'
115
116 Example
117
118 =head2 $and_or
119
120 contains  a list of strings containing and or or. The 1st value is useless.
121
122 =head2 $excluding
123
124 contains 0 or 1. If 1, then the request is negated.
125
126 =head2 $operator
127
128 contains contains,=,start,>,>=,<,<= the = and start work on the complete subfield. The contains operator works on every word in the subfield.
129
130 examples :
131 contains home, search home anywhere.
132 = home, search a string being home.
133
134 =head2 $value
135
136 contains the value to search
137 If it contains a * or a %, then the search is partial.
138
139 =head2 $offset and $length
140
141 returns $length results, beginning at $offset
142
143 =head2 $orderby
144
145 define the field used to order the request. Any field in the biblio/biblioitem tables can be used. DESC is possible too
146
147 (for example title, title DESC,...)
148
149 =head2 RETURNS
150
151 returns an array containing hashes. The hash contains all biblio & biblioitems fields and a reference to an item hash. The "item hash contains one line for each callnumber & the number of items related to the callnumber.
152
153 =cut
154
155 =head2 my $marcnotesarray = &getMARCnotes($dbh,$bibid,$marcflavour);
156
157 Returns a reference to an array containing all the notes stored in the MARC database for the given bibid.
158 $marcflavour ("MARC21" or "UNIMARC") determines which tags are used for retrieving subjects.
159
160 =head2 my $marcsubjctsarray = &getMARCsubjects($dbh,$bibid,$marcflavour);
161
162 Returns a reference to an array containing all the subjects stored in the MARC database for the given bibid.
163 $marcflavour ("MARC21" or "UNIMARC") determines which tags are used for retrieving subjects.
164
165 =cut
166
167 sub catalogsearch {
168         my ($dbh, $tags, $and_or, $excluding, $operator, $value, $offset,$length,$orderby) = @_;
169         warn "@$tags[0], @$and_or[0], @$excluding[0], @$operator[0], @$value[0], $offset,$length,$orderby";
170         # build the sql request. She will look like :
171         # select m1.bibid
172         #               from marc_subfield_table as m1, marc_subfield_table as m2
173         #               where m1.bibid=m2.bibid and
174         #               (m1.subfieldvalue like "Des%" and m2.subfieldvalue like "27%")
175
176         # last minute stripping out of stuff
177         # doesn't work @$value =~ s/\'/ /;
178         # @$value = map { $_ =~ s/\'/ /g } @$value;
179         
180         # "Normal" statements
181         my @normal_tags = ();
182         my @normal_and_or = ();
183         my @normal_operator = ();
184         my @normal_value = ();
185         # Extracts the NOT statements from the list of statements
186         my @not_tags = ();
187         my @not_and_or = ();
188         my @not_operator = ();
189         my @not_value = ();
190         my $any_not = 0;
191         $orderby = "biblio.title" unless $orderby;
192         
193         #last minute stripping out of ' and ,
194 # paul : quoting, it's done a few lines lated.
195 #       foreach $_ (@$value) {
196 #               $_=~ s/\'/ /g;
197 #               $_=~ s/\,/ /g;
198 #       }
199         
200         for(my $i = 0 ; $i <= $#{$value} ; $i++)
201         {
202                 # replace * by %
203                 @$value[$i] =~ s/\*/%/g;
204                 # remove % at the beginning
205                 @$value[$i] =~ s/^%//g;
206             @$value[$i] =~ s/(\.|\?|\:|\!|\'|,|\-|\"|\(|\)|\[|\]|\{|\})/ /g if @$operator[$i] eq "contains";
207                 if(@$excluding[$i])     # NOT statements
208                 {
209                         $any_not = 1;
210                         if(@$operator[$i] eq "contains")
211                         {
212                                 foreach my $word (split(/ /, @$value[$i]))      # if operator is contains, splits the words in separate requests
213                                 {
214                                         # remove the "%" for small word (3 letters. (note : the >4 is due to the % at the end)
215 #                                       warn "word : $word";
216                                         $word =~ s/%//g unless length($word)>4;
217                                         unless (C4::Context->stopwords->{uc($word)} or length($word)==1) {      #it's NOT a stopword => use it. Otherwise, ignore
218                                                 push @not_tags, @$tags[$i];
219                                                 push @not_and_or, "or"; # as request is negated, finds "foo" or "bar" if final request is NOT "foo" and "bar"
220                                                 push @not_operator, @$operator[$i];
221                                                 push @not_value, $word;
222                                         }
223                                 }
224                         }
225                         else
226                         {
227                                 push @not_tags, @$tags[$i];
228                                 push @not_and_or, "or"; # as request is negated, finds "foo" or "bar" if final request is NOT "foo" and "bar"
229                                 push @not_operator, @$operator[$i];
230                                 push @not_value, @$value[$i];
231                         }
232                 }
233                 else    # NORMAL statements
234                 {
235                         if(@$operator[$i] eq "contains") # if operator is contains, splits the words in separate requests
236                         {
237                                 foreach my $word (split(/ /, @$value[$i]))
238                                 {
239                                         # remove the "%" for small word (3 letters. (note : the >4 is due to the % at the end)
240 #                                       warn "word : $word";
241                                         $word =~ s/%//g unless length($word)>4;
242                                         unless (C4::Context->stopwords->{uc($word)} or length($word)==1) {      #it's NOT a stopword => use it. Otherwise, ignore
243                                                 my $tag = substr(@$tags[$i],0,3);
244                                                 my $subf = substr(@$tags[$i],3,1);
245                                                 push @normal_tags, @$tags[$i];
246                                                 push @normal_and_or, "and";     # assumes "foo" and "bar" if "foo bar" is entered
247                                                 push @normal_operator, @$operator[$i];
248                                                 push @normal_value, $word;
249                                         }
250                                 }
251                         }
252                         else
253                         {
254                                 push @normal_tags, @$tags[$i];
255                                 push @normal_and_or, @$and_or[$i];
256                                 push @normal_operator, @$operator[$i];
257                                 push @normal_value, @$value[$i];
258                         }
259                 }
260         }
261
262         # Finds the basic results without the NOT requests
263         my ($sql_tables, $sql_where1, $sql_where2) = create_request($dbh,\@normal_tags, \@normal_and_or, \@normal_operator, \@normal_value);
264
265         $sql_where1 .= "and TO_DAYS( NOW( ) ) - TO_DAYS( biblio.timestamp ) <30" if $orderby =~ "biblio.timestamp";
266         my $sth;
267         if ($sql_where2) {
268                 $sth = $dbh->prepare("select distinct m1.bibid from biblio,biblioitems,marc_biblio,$sql_tables where biblio.biblionumber=marc_biblio.biblionumber and biblio.biblionumber=biblioitems.biblionumber and m1.bibid=marc_biblio.bibid and $sql_where2 and ($sql_where1) order by $orderby");
269                 warn "Q2 : select distinct m1.bibid from biblio,biblioitems,marc_biblio,$sql_tables where biblio.biblionumber=marc_biblio.biblionumber and biblio.biblionumber=biblioitems.biblionumber and m1.bibid=marc_biblio.bibid and $sql_where2 and ($sql_where1) order by $orderby term is  @$value";
270         } else {
271                 $sth = $dbh->prepare("select distinct m1.bibid from biblio,biblioitems,marc_biblio,$sql_tables where biblio.biblionumber=marc_biblio.biblionumber and biblio.biblionumber=biblioitems.biblionumber and m1.bibid=marc_biblio.bibid and $sql_where1 order by $orderby");
272                 warn "Q : select distinct m1.bibid from biblio,biblioitems,marc_biblio,$sql_tables where biblio.biblionumber=marc_biblio.biblionumber and biblio.biblionumber=biblioitems.biblionumber and m1.bibid=marc_biblio.bibid and $sql_where1 order by $orderby";
273         }
274         $sth->execute();
275         my @result = ();
276
277         # Processes the NOT if any and there are results
278         my ($not_sql_tables, $not_sql_where1, $not_sql_where2);
279
280         if( ($sth->rows) && $any_not )  # some results to tune up and some NOT statements
281         {
282                 ($not_sql_tables, $not_sql_where1, $not_sql_where2) = create_request($dbh,\@not_tags, \@not_and_or, \@not_operator, \@not_value);
283
284                 my @tmpresult;
285
286                 while (my ($bibid) = $sth->fetchrow) {
287                         push @tmpresult,$bibid;
288                 }
289                 my $sth_not;
290                 warn "NOT : select distinct m1.bibid from $not_sql_tables where $not_sql_where2 and ($not_sql_where1)";
291                 if ($not_sql_where2) {
292                         $sth_not = $dbh->prepare("select distinct m1.bibid from $not_sql_tables where $not_sql_where2 and ($not_sql_where1)");
293                 } else {
294                         $sth_not = $dbh->prepare("select distinct m1.bibid from $not_sql_tables where $not_sql_where1");
295                 }
296                 $sth_not->execute();
297
298                 if($sth_not->rows)
299                 {
300                         my %not_bibids = ();
301                         while(my $bibid = $sth_not->fetchrow()) {
302                                 $not_bibids{$bibid} = 1;        # populates the hashtable with the bibids matching the NOT statement
303                         }
304
305                         foreach my $bibid (@tmpresult)
306                         {
307                                 if(!$not_bibids{$bibid})
308                                 {
309                                         push @result, $bibid;
310                                 }
311                         }
312                 }
313                 $sth_not->finish();
314         }
315         else    # no NOT statements
316         {
317                 while (my ($bibid) = $sth->fetchrow) {
318                         push @result,$bibid;
319                 }
320         }
321
322         # we have bibid list. Now, loads title and author from [offset] to [offset]+[length]
323         my $counter = $offset;
324         # HINT : biblionumber as bn is important. The hash is fills biblionumber with items.biblionumber.
325         # so if you dont' has an item, you get a not nice empty value.
326         $sth = $dbh->prepare("SELECT biblio.biblionumber as bn,biblio.*, biblioitems.*,marc_biblio.bibid,itemtypes.notforloan
327                                                         FROM biblio, marc_biblio 
328                                                         LEFT JOIN biblioitems on biblio.biblionumber = biblioitems.biblionumber
329                                                         LEFT JOIN itemtypes on itemtypes.itemtype=biblioitems.itemtype
330                                                         WHERE biblio.biblionumber = marc_biblio.biblionumber AND bibid = ?");
331         my @finalresult = ();
332         my @CNresults=();
333         my $totalitems=0;
334         my $oldline;
335         my ($oldbibid, $oldauthor, $oldtitle);
336         my $sth_itemCN = $dbh->prepare("select items.* from items where biblionumber=?");
337         my $sth_issue = $dbh->prepare("select date_due,returndate from issues where itemnumber=?");
338         # parse all biblios between start & end.
339         while (($counter <= $#result) && ($counter <= ($offset + $length))) {
340                 # search & parse all items & note itemcallnumber
341                 $sth->execute($result[$counter]);
342                 my $continue=1;
343                 my $line = $sth->fetchrow_hashref;
344                 my $biblionumber=$line->{bn};
345 #               $continue=0 unless $line->{bn};
346 #               my $lastitemnumber;
347                 $sth_itemCN->execute($biblionumber);
348                 my @CNresults = ();
349                 my $notforloan=1; # to see if there is at least 1 item that can be issued
350                 while (my $item = $sth_itemCN->fetchrow_hashref) {
351                         # parse the result, putting holdingbranch & itemcallnumber in separate array
352                         # then all other fields in the main array
353                         
354                         # search if item is on loan
355                         my $date_due;
356                         $sth_issue->execute($item->{itemnumber});
357                         while (my $loan = $sth_issue->fetchrow_hashref) {
358                                 if ($loan->{date_due} and !$loan->{returndate}) {
359                                         $date_due = $loan->{date_due};
360                                 }
361                         }
362                         # store this item
363                         my %lineCN;
364                         $lineCN{holdingbranch} = $item->{holdingbranch};
365                         $lineCN{itemcallnumber} = $item->{itemcallnumber};
366                         $lineCN{location} = $item->{location};
367                         $lineCN{date_due} = format_date($date_due);
368                         $notforloan=0 unless ($item->{notforloan} or $item->{wthdrawn} or $item->{itemlost});
369                         push @CNresults,\%lineCN;
370                         $totalitems++;
371                 }
372                 # save the biblio in the final array, with item and item issue status
373                 my %newline;
374                 %newline = %$line;
375                 $newline{totitem} = $totalitems;
376                 $newline{biblionumber} = $biblionumber;
377                 $newline{norequests} = 0;
378                 $newline{norequests} = 1 if ($line->{notforloan}); # itemtype not issuable
379                 $newline{norequests} = 1 if (!$line->{notforloan} && $notforloan); # itemtype issuable but all items not issuable for instance
380                 my @CNresults2= @CNresults;
381                 $newline{CN} = \@CNresults2;
382                 $newline{'even'} = 1 if $#finalresult % 2 == 0;
383                 $newline{'odd'} = 1 if $#finalresult % 2 == 1;
384                 $newline{'timestamp'} = format_date($newline{timestamp});
385                 @CNresults = ();
386                 push @finalresult, \%newline;
387                 $totalitems=0;
388                 $counter++;
389         }
390         my $nbresults = $#result+1;
391         return (\@finalresult, $nbresults);
392 }
393
394 # Creates the SQL Request
395
396 sub create_request {
397         my ($dbh,$tags, $and_or, $operator, $value) = @_;
398
399         my $sql_tables; # will contain marc_subfield_table as m1,...
400         my $sql_where1; # will contain the "true" where
401         my $sql_where2 = "("; # will contain m1.bibid=m2.bibid
402         my $nb_active=0; # will contain the number of "active" entries. an entry is active if a value is provided.
403         my $nb_table=1; # will contain the number of table. ++ on each entry EXCEPT when an OR  is provided.
404
405         my $maxloop=8; # the maximum number of words to avoid a too complex search.
406         $maxloop = @$value if @$value<$maxloop;
407         
408         for(my $i=0; $i<=$maxloop;$i++) {
409                 if (@$value[$i]) {
410                         $nb_active++;
411                         if ($nb_active==1) {
412                                 if (@$operator[$i] eq "start") {
413                                         $sql_tables .= "marc_subfield_table as m$nb_table,";
414                                         $sql_where1 .= "(m1.subfieldvalue like ".$dbh->quote("@$value[$i]%");
415                                         if (@$tags[$i]) {
416                                                 $sql_where1 .=" and concat(m1.tag,m1.subfieldcode) in (@$tags[$i])";
417                                         }
418                                         $sql_where1.=")";
419                                 } elsif (@$operator[$i] eq "contains") {
420                                         $sql_tables .= "marc_word as m$nb_table,";
421                                         $sql_where1 .= "(m1.word  like ".$dbh->quote("@$value[$i]");
422                                         if (@$tags[$i]) {
423                                                  $sql_where1 .=" and m1.tagsubfield in (@$tags[$i])";
424                                         }
425                                         $sql_where1.=")";
426                                 } else {
427                                         $sql_tables .= "marc_subfield_table as m$nb_table,";
428                                         $sql_where1 .= "(m1.subfieldvalue @$operator[$i] ".$dbh->quote("@$value[$i]");
429                                         if (@$tags[$i]) {
430                                                  $sql_where1 .=" and concat(m1.tag,m1.subfieldcode) in (@$tags[$i])";
431                                         }
432                                         $sql_where1.=")";
433                                 }
434                         } else {
435                                 if (@$operator[$i] eq "start") {
436                                         $nb_table++;
437                                         $sql_tables .= "marc_subfield_table as m$nb_table,";
438                                         $sql_where1 .= "@$and_or[$i] (m$nb_table.subfieldvalue like ".$dbh->quote("@$value[$i]%");
439                                         if (@$tags[$i]) {
440                                                 $sql_where1 .=" and concat(m$nb_table.tag,m$nb_table.subfieldcode) in (@$tags[$i])";
441                                         }
442                                         $sql_where1.=")";
443                                         $sql_where2 .= "m1.bibid=m$nb_table.bibid and ";
444                                 } elsif (@$operator[$i] eq "contains") {
445                                         if (@$and_or[$i] eq 'and') {
446                                                 $nb_table++;
447                                                 $sql_tables .= "marc_word as m$nb_table,";
448                                                 $sql_where1 .= "@$and_or[$i] (m$nb_table.word like ".$dbh->quote("@$value[$i]");
449                                                 if (@$tags[$i]) {
450                                                         $sql_where1 .=" and m$nb_table.tagsubfield in(@$tags[$i])";
451                                                 }
452                                                 $sql_where1.=")";
453                                                 $sql_where2 .= "m1.bibid=m$nb_table.bibid and ";
454                                         } else {
455                                                 $sql_where1 .= "@$and_or[$i] (m$nb_table.word like ".$dbh->quote("@$value[$i]");
456                                                 if (@$tags[$i]) {
457                                                         $sql_where1 .="  and m$nb_table.tagsubfield in (@$tags[$i])";
458                                                 }
459                                                 $sql_where1.=")";
460                                                 $sql_where2 .= "m1.bibid=m$nb_table.bibid and ";
461                                         }
462                                 } else {
463                                         $nb_table++;
464                                         $sql_tables .= "marc_subfield_table as m$nb_table,";
465                                         $sql_where1 .= "@$and_or[$i] (m$nb_table.subfieldvalue @$operator[$i] ".$dbh->quote(@$value[$i]);
466                                         if (@$tags[$i]) {
467                                                 $sql_where1 .="  and concat(m$nb_table.tag,m$nb_table.subfieldcode) in (@$tags[$i])";
468                                         }
469                                         $sql_where2 .= "m1.bibid=m$nb_table.bibid and ";
470                                         $sql_where1.=")";
471                                 }
472                         }
473                 }
474         }
475
476         if($sql_where2 ne "(")  # some datas added to sql_where2, processing
477         {
478                 $sql_where2 = substr($sql_where2, 0, (length($sql_where2)-5)); # deletes the trailing ' and '
479                 $sql_where2 .= ")";
480         }
481         else    # no sql_where2 statement, deleting '('
482         {
483                 $sql_where2 = "";
484         }
485         chop $sql_tables;       # deletes the trailing ','
486         return ($sql_tables, $sql_where1, $sql_where2);
487 }
488
489 sub getMARCnotes {
490         my ($dbh, $bibid, $marcflavour) = @_;
491         my ($mintag, $maxtag);
492         if ($marcflavour eq "MARC21") {
493                 $mintag = "500";
494                 $maxtag = "599";
495         } else {           # assume unimarc if not marc21
496                 $mintag = "300";
497                 $maxtag = "399";
498         }
499
500         my $sth=$dbh->prepare("SELECT subfieldvalue,tag FROM marc_subfield_table WHERE bibid=? AND tag BETWEEN ? AND ? ORDER BY tagorder");
501
502         $sth->execute($bibid,$mintag,$maxtag);
503
504         my @marcnotes;
505         my $note = "";
506         my $tag = "";
507         my $marcnote;
508
509         while (my $data=$sth->fetchrow_arrayref) {
510                 my $value=$data->[0];
511                 my $thistag=$data->[1];
512                 if ($value=~/\.$/) {
513                         $value=$value . "  ";
514                 }
515                 if ($thistag ne $tag && $note ne "") {
516                         $marcnote = {marcnote => $note,};
517                         push @marcnotes, $marcnote;
518                         $note=$value;
519                         $tag=$thistag;
520                 }
521                 if ($note ne $value) {
522                         $note = $note." ".$value;
523                 }
524         }
525
526         if ($note) {
527                 $marcnote = {marcnote => $note};
528                 push @marcnotes, $marcnote;   #load last tag into array
529         }
530
531         $sth->finish;
532         $dbh->disconnect;
533
534         my $marcnotesarray=\@marcnotes;
535         return $marcnotesarray;
536 }  # end getMARCnotes
537
538
539 sub getMARCsubjects {
540     my ($dbh, $bibid, $marcflavour) = @_;
541         my ($mintag, $maxtag);
542         if ($marcflavour eq "MARC21") {
543                 $mintag = "600";
544                 $maxtag = "699";
545         } else {           # assume unimarc if not marc21
546                 $mintag = "600";
547                 $maxtag = "619";
548         }
549         my $sth=$dbh->prepare("SELECT subfieldvalue,subfieldcode FROM marc_subfield_table WHERE bibid=? AND tag BETWEEN ? AND ? ORDER BY tagorder");
550
551         $sth->execute($bibid,$mintag,$maxtag);
552
553         my @marcsubjcts;
554         my $subjct = "";
555         my $subfield = "";
556         my $marcsubjct;
557
558         while (my $data=$sth->fetchrow_arrayref) {
559                 my $value = $data->[0];
560                 my $subfield = $data->[1];
561                 if ($subfield eq "a" && $value ne $subjct) {
562                         $marcsubjct = {MARCSUBJCT => $value,};
563                         push @marcsubjcts, $marcsubjct;
564                         $subjct = $value;
565                 }
566         }
567
568         $sth->finish;
569         $dbh->disconnect;
570
571         my $marcsubjctsarray=\@marcsubjcts;
572         return $marcsubjctsarray;
573 }  #end getMARCsubjects
574
575 END { }       # module clean-up code here (global destructor)
576
577 1;
578 __END__
579
580 =back
581
582 =head1 AUTHOR
583
584 Koha Developement team <info@koha.org>
585
586 =cut