Lines 71-77
sub BreedingSearch {
Link Here
|
71 |
my ($search,$isbn) = @_; |
71 |
my ($search,$isbn) = @_; |
72 |
my $dbh = C4::Context->dbh; |
72 |
my $dbh = C4::Context->dbh; |
73 |
my $count = 0; |
73 |
my $count = 0; |
74 |
my ($query,@bind); |
74 |
my ( $query, @cond, @bind ); |
75 |
my $sth; |
75 |
my $sth; |
76 |
my @results; |
76 |
my @results; |
77 |
|
77 |
|
Lines 81-101
sub BreedingSearch {
Link Here
|
81 |
$query = "SELECT import_record_id, file_name, isbn, title, author |
81 |
$query = "SELECT import_record_id, file_name, isbn, title, author |
82 |
FROM import_biblios |
82 |
FROM import_biblios |
83 |
JOIN import_records USING (import_record_id) |
83 |
JOIN import_records USING (import_record_id) |
84 |
JOIN import_batches USING (import_batch_id) |
84 |
JOIN import_batches USING (import_batch_id)"; |
85 |
WHERE "; |
85 |
|
86 |
@bind=(); |
|
|
87 |
if (defined($search) && length($search)>0) { |
86 |
if (defined($search) && length($search)>0) { |
88 |
$search =~ s/(\s+)/\%/g; |
87 |
$search =~ s/(\s+)/\%/g; |
89 |
$query .= "title like ? OR author like ?"; |
88 |
push @cond, 'title like ? OR author like ?'; |
90 |
push(@bind,"%$search%", "%$search%"); |
89 |
push @bind, "%$search%", "%$search%"; |
91 |
} |
|
|
92 |
if ($#bind!=-1 && defined($isbn) && length($isbn)>0) { |
93 |
$query .= " and "; |
94 |
} |
90 |
} |
95 |
if (defined($isbn) && length($isbn)>0) { |
91 |
if (defined($isbn) && length($isbn)>0) { |
96 |
$query .= "isbn like ?"; |
92 |
push @cond, 'isbn like ?'; |
97 |
push(@bind,"$isbn%"); |
93 |
push @bind, "$isbn%"; |
98 |
} |
94 |
} |
|
|
95 |
|
96 |
$query .= ' WHERE ' . join( ' AND ', @cond ) if @cond; |
97 |
|
99 |
$sth = $dbh->prepare($query); |
98 |
$sth = $dbh->prepare($query); |
100 |
$sth->execute(@bind); |
99 |
$sth->execute(@bind); |
101 |
while (my $data = $sth->fetchrow_hashref) { |
100 |
while (my $data = $sth->fetchrow_hashref) { |