Browse files

Merge branch 'Bug4340' into ptfs-master

  • Loading branch information...
2 parents 965ff71 + 5c0f1d3 commit 1f86c8f2ed095d5130b8beceebb499cbe65341e3 J. David Bavousett committed Mar 24, 2010
Showing with 16 additions and 10 deletions.
  1. +16 −10 C4/Members.pm
View
26 C4/Members.pm
@@ -206,22 +206,28 @@ sub SearchMember {
$query.=" borrowers.branchcode =".$dbh->quote(C4::Context->userenv->{'branch'})." AND " unless (C4::Context->userenv->{'branch'} eq "insecure");
}
}
- $query.="((surname LIKE ? OR surname LIKE ?
- OR firstname LIKE ? OR firstname LIKE ?
- OR othernames LIKE ? OR othernames LIKE ?)
+ $query.="((surname LIKE ? OR (surname LIKE ? AND surname REGEXP ?)
+ OR firstname LIKE ? OR (firstname LIKE ? AND firstname REGEXP ?)
+ OR othernames LIKE ? OR (othernames LIKE ? AND othernames REGEXP ?))
" .
($category_type?" AND category_type = ".$dbh->quote($category_type):"");
+ my $regex = '[[:punct:][:space:]]'.$data[0];
@bind = (
- "$data[0]%", "% $data[0]%", "$data[0]%", "% $data[0]%",
- "$data[0]%", "% $data[0]%"
+ "$data[0]%", "%$data[0]%", $regex,
+ "$data[0]%", "%$data[0]%", $regex,
+ "$data[0]%", "%$data[0]%", $regex
);
for ( my $i = 1 ; $i < $count ; $i++ ) {
- $query = $query . " AND (" . " surname LIKE ? OR surname LIKE ?
- OR firstname LIKE ? OR firstname LIKE ?
- OR othernames LIKE ? OR othernames LIKE ?)";
+ $query = $query . " AND (" . " surname LIKE ? OR (surname LIKE ? AND surname REGEXP ?)
+ OR firstname LIKE ? OR (firstname LIKE ? AND firstname REGEXP ?)
+ OR othernames LIKE ? OR (othernames LIKE ? AND othernames REGEXP ?))";
+ $regex = '[[:punct:][:space:]]'.$data[$i];
push( @bind,
- "$data[$i]%", "% $data[$i]%", "$data[$i]%",
- "% $data[$i]%", "$data[$i]%", "% $data[$i]%" );
+ "$data[$i]%", "%$data[$i]%", $regex,
+ "$data[$i]%", "%$data[$i]%", $regex,
+ "$data[$i]%", "%$data[$i]%", $regex
+ );
+
# FIXME - .= <<EOT;
}

0 comments on commit 1f86c8f

Please sign in to comment.