koha-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Koha-cvs] CVS: koha/C4 Context.pm,1.17,1.18


From: Paul POULAIN
Subject: [Koha-cvs] CVS: koha/C4 Context.pm,1.17,1.18
Date: Tue, 14 Dec 2004 07:48:36 -0800

Update of /cvsroot/koha/koha/C4
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29012/C4

Modified Files:
        Context.pm 
Log Message:
an improvement has been done in DB calls that needs a new index. It's 
automatically added in fresh installs, but for updates, run the following SQL 
command :
ALTER TABLE `marc_subfield_structure` ADD INDEX ( `kohafield` ) 

Index: Context.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Context.pm,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -r1.17 -r1.18
*** Context.pm  8 Dec 2004 10:08:41 -0000       1.17
--- Context.pm  14 Dec 2004 15:48:34 -0000      1.18
***************
*** 231,234 ****
--- 231,235 ----
        $self->{"dbh"} = undef;         # Database handle
        $self->{"stopwords"} = undef; # stopwords list
+       $self->{"marcfromkohafield"} = undef; # the hash with relations between 
koha table fields and MARC field/subfield
  
        bless $self, $class;
***************
*** 516,519 ****
--- 517,560 ----
  }
  
+ =item marcfromkohafield
+ 
+   $dbh = C4::Context->marcfromkohafield;
+ 
+ Returns a hash with marcfromkohafield.
+ 
+ This hash is cached for future use: if you call
+ C<C4::Context-E<gt>marcfromkohafield> twice, you will get the same hash 
without real DB access
+ 
+ =cut
+ #'
+ sub marcfromkohafield
+ {
+       my $retval = {};
+ 
+       # If the hash already exists, return it.
+       return $context->{"marcfromkohafield"} if 
defined($context->{"marcfromkohafield"});
+ 
+       # No hash. Create one.
+       $context->{"marcfromkohafield"} = &_new_marcfromkohafield();
+ 
+       return $context->{"marcfromkohafield"};
+ }
+ 
+ # _new_marcfromkohafield
+ # Internal helper function (not a method!). This creates a new
+ # hash with stopwords
+ sub _new_marcfromkohafield
+ {
+       my $dbh = C4::Context->dbh;
+       my $marcfromkohafield;
+       my $sth = $dbh->prepare("select 
frameworkcode,kohafield,tagfield,tagsubfield from marc_subfield_structure where 
kohafield > ''");
+       $sth->execute;
+       while (my ($frameworkcode,$kohafield,$tagfield,$tagsubfield) = 
$sth->fetchrow) {
+               my $retval = {};
+               $marcfromkohafield->{$frameworkcode}->{$kohafield} = 
[$tagfield,$tagsubfield];
+       }
+       return $marcfromkohafield;
+ }
+ 
  =item stopwords
  
***************
*** 556,559 ****
--- 597,602 ----
  }
  
+ 
+ 
  1;
  __END__




reply via email to

[Prev in Thread] Current Thread [Next in Thread]