3 # Copyright 2000-2006 Katipo Communications
5 # This file is part of Koha.
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
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.
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
30 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
32 # set the version for version checking
33 $VERSION = do { my @v = '$Revision$' =~ /\d+/g;
34 shift(@v) . "." . join( "_", map { sprintf "%03d", $_ } @v );
39 C4::Search - Functions for searching the Koha catalog and other databases
47 This module provides the searching facilities for the Koha catalog and
57 @EXPORT = qw(search get_record get_xml_record);
59 # make all your functions, whether exported or not;
62 my ( $search, $type, $number ) = @_;
63 my $dbh = C4::Context->dbh();
65 my $Zconn = C4::Context->Zconn;
68 if ( $type eq 'CQL' ) {
70 if ( $search->{'cql'} ) {
71 $string = $search->{'cql'};
74 foreach my $var ( keys %$search ) {
75 $string .= "$var=\"$search->{$var}\" ";
78 $q = new ZOOM::Query::CQL2RPN( $string, $Zconn );
83 $rs = $Zconn->search($q);
87 print "Error ", $@->code(), ": ", $@->message(), "\n";
91 while ( $i < $n && $i < $number ) {
92 $raw = $rs->record($i)->raw();
93 my $record = MARC::Record->new_from_xml($raw, 'UTF-8');
94 my $line = MARCmarc2koha( $dbh, $record );
105 # pass in an id (biblionumber at this stage) and get back a MARC record
108 my $Zconn = C4::Context->Zconn;
110 my $string = "identifier=$id";
111 # my $string = "title=delete";
114 $q = new ZOOM::Query::CQL2RPN( $string, $Zconn);
116 # my $rs = $Zconn->search_pqf("\@attr 1=12 $id");
117 my $rs = $Zconn->search($q);
120 $raw = $rs->record(0)->raw();
125 warn "Error ", $@->code(), ": ", $@->message(), "\n";
128 my $record = MARC::Record->new_from_xml($raw, 'UTF-8');
135 # pass in an id (biblionumber at this stage) and get back a MARC record
138 my $Zconn = C4::Context->Zconn;
140 my $string = "identifier=$id";
141 # my $string = "title=delete";
144 $q = new ZOOM::Query::CQL2RPN( $string, $Zconn);
146 # my $rs = $Zconn->search_pqf("\@attr 1=12 $id");
147 my $rs = $Zconn->search($q);
150 $raw = $rs->record(0)->raw();
155 warn "Error ", $@->code(), ": ", $@->message(), "\n";
170 Koha Developement team <info@koha.org>