-my $dbh = C4::Context->dbh;
-my $sql = qq(SELECT surname, firstname, cardnumber, address, city, zipcode
- FROM borrowers
- WHERE surname LIKE ?
- OR firstname LIKE ?
- ORDER BY surname, firstname);
- #"OR cardnumber LIKE '" . $query . "%' " .
-my $sth = $dbh->prepare( $sql );
-$sth->execute("$query%", "$query%");
-while ( my $rec = $sth->fetchrow_hashref ) {
- print $rec->{surname} . ", " . $rec->{firstname} . "\t" .
- $rec->{cardnumber} . "\t" .
- $rec->{address} . "\t" .
- $rec->{city} . "\t" .
- $rec->{zip} .
- "\n";
-}
+print map $_->{surname} . ", " . $_->{firstname} . "\t" .
+ $_->{cardnumber} . "\t" .
+ $_->{address} . "\t" .
+ $_->{city} . "\t" .
+ $_->{zipcode} . "\t" .
+ $_->{country} .
+ "\n",
+ @{ Search($query, [qw(surname firstname cardnumber)], [10], [qw(surname firstname cardnumber address city zipcode country)]) };