+
+=head2 GetBorrowersFromSurname
+
+=over 4
+
+\@resutlts = GetBorrowersFromSurname($surname)
+this function get the list of borrower names like $surname.
+return :
+the table of results in @results
+
+=back
+
+=cut
+sub GetBorrowersFromSurname {
+ my ($searchstring)=@_;
+ my $dbh = C4::Context->dbh;
+ $searchstring=~ s/\'/\\\'/g;
+ my @data=split(' ',$searchstring);
+ my $count=@data;
+ my $query = qq|
+ SELECT surname,firstname
+ FROM borrowers
+ WHERE (surname like ?)
+ ORDER BY surname
+ |;
+ my $sth=$dbh->prepare($query);
+ $sth->execute("$data[0]%");
+ my @results;
+ my $count = 0;
+ while (my $data=$sth->fetchrow_hashref){
+ push(@results,$data);
+ $count++;
+ }
+ $sth->finish;
+ return ($count,\@results);
+}
+
+END { } # module clean-up code here (global destructor)
+