[Koha-cvs] CVS: koha/C4 Breeding.pm,1.7,1.7.2.1 Search.pm,1.99.2.4,1.99.2.5

Paul POULAIN tipaul at users.sourceforge.net
Fri Mar 18 09:57:08 CET 2005


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

Modified Files:
      Tag: rel_2_2
	Breeding.pm Search.pm 
Log Message:
moving BreedingSearch function to Breeding.pm, a more logic place

Index: Breeding.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Breeding.pm,v
retrieving revision 1.7
retrieving revision 1.7.2.1
diff -C2 -r1.7 -r1.7.2.1
*** Breeding.pm	8 Dec 2004 10:11:51 -0000	1.7
--- Breeding.pm	18 Mar 2005 08:57:04 -0000	1.7.2.1
***************
*** 53,57 ****
  
  @ISA = qw(Exporter);
! @EXPORT = qw(&ImportBreeding);
  
  sub  ImportBreeding {
--- 53,57 ----
  
  @ISA = qw(Exporter);
! @EXPORT = qw(&ImportBreeding &BreedingSearch);
  
  sub  ImportBreeding {
***************
*** 125,127 ****
--- 125,178 ----
  }
  
+ 
+ =item BreedingSearch
+ 
+   ($count, @results) = &BreedingSearch($title,$isbn,$random);
+ C<$title> contains the title,
+ C<$isbn> contains isbn or issn,
+ C<$random> contains the random seed from a z3950 search.
+ 
+ C<$count> is the number of items in C<@results>. C<@results> is an
+ array of references-to-hash; the keys are the items from the C<marc_breeding> table of the Koha database.
+ 
+ =cut
+ 
+ sub BreedingSearch {
+ 	my ($title,$isbn,$z3950random) = @_;
+ 	my $dbh   = C4::Context->dbh;
+ 	my $count = 0;
+ 	my ($query, at bind);
+ 	my $sth;
+ 	my @results;
+ 
+ 	$query = "Select id,file,isbn,title,author from marc_breeding where ";
+ 	if ($z3950random) {
+ 		$query .= "z3950random = ?";
+ 		@bind=($z3950random);
+ 	} else {
+ 	    @bind=();
+ 		if ($title) {
+ 			$query .= "title like ?";
+ 			push(@bind,"$title%");
+ 		}
+ 		if ($title && $isbn) {
+ 			$query .= " and ";
+ 		}
+ 		if ($isbn) {
+ 			$query .= "isbn like ?";
+ 			push(@bind,"$isbn%");
+ 		}
+ 	}
+ 	$sth   = $dbh->prepare($query);
+ 	$sth->execute(@bind);
+ 	while (my $data = $sth->fetchrow_hashref) {
+ 			$results[$count] = $data;
+ 			$count++;
+ 	} # while
+ 
+ 	$sth->finish;
+ 	return($count, @results);
+ } # sub breedingsearch
+ 
+ 
  END { }       # module clean-up code here (global destructor)

Index: Search.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Search.pm,v
retrieving revision 1.99.2.4
retrieving revision 1.99.2.5
diff -C2 -r1.99.2.4 -r1.99.2.5
*** Search.pm	28 Feb 2005 14:25:19 -0000	1.99.2.4
--- Search.pm	18 Mar 2005 08:57:04 -0000	1.99.2.5
***************
*** 65,69 ****
  &addauthor &bibitems &barcodes &findguarantees &allissues
  &findguarantor &getwebsites &getwebbiblioitems &catalogsearch &itemcount2
! &isbnsearch &breedingsearch &getbranchname &getborrowercategory);
  # make all your functions, whether exported or not;
  
--- 65,69 ----
  &addauthor &bibitems &barcodes &findguarantees &allissues
  &findguarantor &getwebsites &getwebbiblioitems &catalogsearch &itemcount2
! &isbnsearch &getbranchname &getborrowercategory);
  # make all your functions, whether exported or not;
  
***************
*** 2444,2499 ****
  
  
- =item breedingsearch
- 
-   ($count, @results) = &breedingsearch($title,$isbn,$random);
- C<$title> contains the title,
- C<$isbn> contains isbn or issn,
- C<$random> contains the random seed from a z3950 search.
- 
- C<$count> is the number of items in C<@results>. C<@results> is an
- array of references-to-hash; the keys are the items from the C<marc_breeding> table of the Koha database.
- 
- =cut
- 
- sub breedingsearch {
- 	my ($title,$isbn,$z3950random) = @_;
- 	my $dbh   = C4::Context->dbh;
- 	my $count = 0;
- 	my ($query, at bind);
- 	my $sth;
- 	my @results;
- 
- 	$query = "Select id,file,isbn,title,author from marc_breeding where ";
- 	if ($z3950random) {
- 		$query .= "z3950random = ?";
- 		@bind=($z3950random);
- 	} else {
- 	    @bind=();
- 		if ($title) {
- 			$query .= "title like ?";
- 			push(@bind,"$title%");
- 		}
- 		if ($title && $isbn) {
- 			$query .= " and ";
- 		}
- 		if ($isbn) {
- 			$query .= "isbn like ?";
- 			push(@bind,"$isbn%");
- 		}
- 	}
- 	$sth   = $dbh->prepare($query);
- 	$sth->execute(@bind);
- 	while (my $data = $sth->fetchrow_hashref) {
- 			$results[$count] = $data;
- 			$count++;
- 	} # while
- 
- 	$sth->finish;
- 	return($count, @results);
- } # sub breedingsearch
- 
- 
- 
- 
  
  =item isbnsearch
--- 2444,2447 ----





More information about the Koha-cvs mailing list