[Koha-cvs] koha/C4 Biblio.pm [rel_2_2]
paul poulain
paul at koha-fr.org
Wed Nov 22 14:58:12 CET 2006
CVSROOT: /cvsroot/koha
Module name: koha
Branch: rel_2_2
Changes by: paul poulain <tipaul> 06/11/22 13:58:12
Modified files:
C4 : Biblio.pm
Log message:
there are some strange problems with mysql_fetchrow_hashref, that reorders silently the hashref returned.
This hack fixes them by retrieving the results in an array & rebuilding the MARC record from that.
This function is used in acquisition, when the librarian creates a new order from a new biblio : the MARC::Record was incorrect (at least in UNIMARC, but this fix should change nothing in MARC21)
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Biblio.pm?cvsroot=koha&only_with_tag=rel_2_2&r1=1.115.2.62&r2=1.115.2.63
Patches:
Index: Biblio.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Biblio.pm,v
retrieving revision 1.115.2.62
retrieving revision 1.115.2.63
diff -u -b -r1.115.2.62 -r1.115.2.63
--- Biblio.pm 13 Oct 2006 08:34:21 -0000 1.115.2.62
+++ Biblio.pm 22 Nov 2006 13:58:11 -0000 1.115.2.63
@@ -26,7 +26,7 @@
use vars qw($VERSION @ISA @EXPORT);
# set the version for version checking
-$VERSION = do { my @v = '$Revision: 1.115.2.62 $' =~ /\d+/g;
+$VERSION = do { my @v = '$Revision: 1.115.2.63 $' =~ /\d+/g;
shift(@v) . "." . join("_", map {sprintf "%03d", $_ } @v); };
@ISA = qw(Exporter);
@@ -893,56 +893,46 @@
#--- if bibid, then retrieve old-style koha data
if ( $biblionumber > 0 ) {
my $sth2 =
- $dbh->prepare(
-"select biblionumber,title,unititle,notes,abstract,serial,seriestitle,copyrightdate,timestamp
- from biblio where biblionumber=?"
+ $dbh->prepare("SELECT biblio.biblionumber,title,itemtype,author,unititle,biblio.notes,abstract,
+ serial,seriestitle,copyrightdate,biblio.timestamp,
+ biblioitemnumber,volume,number,classification,
+ url,isbn,issn,dewey,subclass,publicationyear,publishercode,
+ volumedate,volumeddesc,illus,pages,biblioitems.notes AS bnotes,size,place
+ FROM biblio
+ LEFT JOIN biblioitems on biblio.biblionumber=biblioitems.biblionumber
+ WHERE biblio.biblionumber=?"
);
$sth2->execute($biblionumber);
- my $row = $sth2->fetchrow_hashref;
- my $code;
- foreach $code ( keys %$row ) {
- if ( $row->{$code} ) {
- &MARCkoha2marcOnefield( $sth, $record, "biblio." . $code,
- $row->{$code}, '');
- }
+ my @row = $sth2->fetchrow;
+ &MARCkoha2marcOnefield( $sth, $record, "biblio.biblionumber", $row[0], '') if $row[0];
+ &MARCkoha2marcOnefield( $sth, $record, "biblio.title", $row[1], '') if $row[1];
+ &MARCkoha2marcOnefield( $sth, $record, "biblioitems.itemtype", $row[2], '') if $row[2];
+ &MARCkoha2marcOnefield( $sth, $record, "biblio.author", $row[3], '') if $row[3];
+ &MARCkoha2marcOnefield( $sth, $record, "biblio.unititle", $row[4], '') if $row[4];
+ &MARCkoha2marcOnefield( $sth, $record, "biblio.notes", $row[5], '') if $row[5];
+ &MARCkoha2marcOnefield( $sth, $record, "biblio.abstract", $row[6], '') if $row[6];
+ &MARCkoha2marcOnefield( $sth, $record, "biblio.serial", $row[7], '') if $row[7];
+ &MARCkoha2marcOnefield( $sth, $record, "biblio.seriestitle", $row[8], '') if $row[8];
+ &MARCkoha2marcOnefield( $sth, $record, "biblio.copyrightdate", $row[9], '') if $row[9];
+ &MARCkoha2marcOnefield( $sth, $record, "biblio.timestamp", $row[10], '') if $row[10];
+ &MARCkoha2marcOnefield( $sth, $record, "biblioitems.biblioitemnumber", $row[11], '') if $row[11];
+ &MARCkoha2marcOnefield( $sth, $record, "biblioitems.volume", $row[12], '') if $row[12];
+ &MARCkoha2marcOnefield( $sth, $record, "biblioitems.number", $row[13], '') if $row[13];
+ &MARCkoha2marcOnefield( $sth, $record, "biblioitems.classification", $row[14], '') if $row[14];
+ &MARCkoha2marcOnefield( $sth, $record, "biblioitems.url", $row[15], '') if $row[15];
+ &MARCkoha2marcOnefield( $sth, $record, "biblioitems.isbn", $row[16], '') if $row[16];
+ &MARCkoha2marcOnefield( $sth, $record, "biblioitems.issn", $row[17], '') if $row[17];
+ &MARCkoha2marcOnefield( $sth, $record, "biblioitems.dewey", $row[18], '') if $row[18];
+ &MARCkoha2marcOnefield( $sth, $record, "biblioitems.subclass", $row[19], '') if $row[19];
+ &MARCkoha2marcOnefield( $sth, $record, "biblioitems.publicationyear", $row[20], '') if $row[20];
+ &MARCkoha2marcOnefield( $sth, $record, "biblioitems.volumedate", $row[21], '') if $row[21];
+ &MARCkoha2marcOnefield( $sth, $record, "biblioitems.volumeddesc", $row[22], '') if $row[22];
+ &MARCkoha2marcOnefield( $sth, $record, "biblioitems.illus", $row[23], '') if $row[23];
+ &MARCkoha2marcOnefield( $sth, $record, "biblioitems.pages", $row[24], '') if $row[24];
+ &MARCkoha2marcOnefield( $sth, $record, "biblioitems.notes", $row[25], '') if $row[25];
+ &MARCkoha2marcOnefield( $sth, $record, "biblioitems.size", $row[26], '') if $row[26];
+ &MARCkoha2marcOnefield( $sth, $record, "biblioitems.place", $row[27], '') if $row[27];
}
- #for an unknown reason, mysql fetchrow_hashref returns author BEFORE the title, even if you want it after
- # that makes a problem for UNIMARC where we have 200 $atitle $fauthor => the record appears $f $a.
- # this dirty hack fixes the problem
- $sth2 = $dbh->prepare("select author from biblio where biblionumber=?");
- $sth2->execute($biblionumber);
- $row = $sth2->fetchrow_hashref;
- $code;
- foreach $code ( keys %$row ) {
- if ( $row->{$code} ) {
- &MARCkoha2marcOnefield( $sth, $record, "biblio." . $code,
- $row->{$code}, '');
- }
- }
- }
-
- #--- if biblioitem, then retrieve old-style koha data
- if ( $biblioitemnumber > 0 ) {
- my $sth2 =
- $dbh->prepare(
- " SELECT biblioitemnumber,biblionumber,volume,number,classification,
- itemtype,url,isbn,issn,dewey,subclass,publicationyear,publishercode,
- volumedate,volumeddesc,timestamp,illus,pages,notes AS bnotes,size,place
- FROM biblioitems
- WHERE biblioitemnumber=?
- "
- );
- $sth2->execute($biblioitemnumber);
- my $row = $sth2->fetchrow_hashref;
- my $code;
- foreach $code ( keys %$row ) {
- if ( $row->{$code} ) {
- &MARCkoha2marcOnefield( $sth, $record, "biblioitems." . $code,
- $row->{$code},'' );
- }
- }
- }
-
# other fields => additional authors, subjects, subtitles
my $sth2 =
$dbh->prepare(
@@ -967,6 +957,7 @@
&MARCkoha2marcOnefield( $sth, $record, "bibliosubtitle.subtitle",
$row->{'subtitle'},'' );
}
+# warn "REC : ".$record->as_formatted;
return $record;
}
@@ -3014,8 +3005,13 @@
=cut
-# $Id: Biblio.pm,v 1.115.2.62 2006/10/13 08:34:21 tipaul Exp $
+# $Id: Biblio.pm,v 1.115.2.63 2006/11/22 13:58:11 tipaul Exp $
# $Log: Biblio.pm,v $
+# Revision 1.115.2.63 2006/11/22 13:58:11 tipaul
+# there are some strange problems with mysql_fetchrow_hashref, that reorders silently the hashref returned.
+# This hack fixes them by retrieving the results in an array & rebuilding the MARC record from that.
+# This function is used in acquisition, when the librarian creates a new order from a new biblio : the MARC::Record was incorrect (at least in UNIMARC, but this fix should change nothing in MARC21)
+#
# Revision 1.115.2.62 2006/10/13 08:34:21 tipaul
# removing warn
#
More information about the Koha-cvs
mailing list