From cdfb9d9acb13877cc67a2ffd0e4f30f4fd10ecc5 Mon Sep 17 00:00:00 2001 From: rangi Date: Tue, 14 Feb 2006 04:00:23 +0000 Subject: [PATCH] Work in progress still, committing for testing --- C4/Search.pm | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/C4/Search.pm b/C4/Search.pm index 6cb3e72721..86b723db1b 100755 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -21,6 +21,9 @@ use strict; use ZOOM; use Smart::Comments; use C4::Context; +use MARC::Record; +use MARC::File::XML; +use C4::Biblio; require Exporter; @@ -55,13 +58,16 @@ other databases. sub search { my ($search,$type)=@_; + my $dbh=C4::Context->dbh(); my $q; my $host=C4::Context->config("zebraserver"); my $port=C4::Context->config("zebraport"); my $intranetdir=C4::Context->config("intranetdir"); + my $database="koha3"; my $Zconn; + my $raw; eval { - $Zconn = new ZOOM::Connection($host,$port); + $Zconn = new ZOOM::Connection("$host:$port/$database"); }; if ($@) { warn "Error ", $@->code(), ": ", $@->message(), "\n"; @@ -73,17 +79,33 @@ sub search { $string.="$var=\"$search->{$var}\" "; } $Zconn->option(cqlfile => "$intranetdir/zebra/pqf.properties"); - $Zconn->option(preferredRecordSyntax => "xml"); + $Zconn->option(preferredRecordSyntax => "usmarc"); $q = new ZOOM::Query::CQL2RPN( $string, $Zconn); } eval { my $rs = $Zconn->search($q); my $n = $rs->size(); - ###$rs->record(0)->render(); + if ($n >0){ + $raw=$rs->record(0)->raw(); + } +# print "here is $n"; +# $raw=$rs->record(0)->raw(); + print $raw; + + }; if ($@) { print "Error ", $@->code(), ": ", $@->message(), "\n"; } + my $record = MARC::Record->new_from_usmarc($raw); + ### $record + # transform it into a meaningul hash + my $line = MARCmarc2koha($dbh,$record); + ### $line + my $biblionumber=$line->{biblionumber}; + my $title=$line->{title}; + + } 1; __END__ -- 2.39.5