[Bio] / Sprout / CustomAttributes.pm Repository:
ViewVC logotype

Diff of /Sprout/CustomAttributes.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.33, Tue Aug 12 06:06:02 2008 UTC revision 1.36, Tue Sep 9 21:01:25 2008 UTC
# Line 1979  Line 1979 
1979      my ($self, $query, $table, @values) = @_;      my ($self, $query, $table, @values) = @_;
1980      # Declare the return value.      # Declare the return value.
1981      my @retVal = ();      my @retVal = ();
1982        # We use this hash to check for duplicates.
1983        my %dupHash = ();
1984      # Get the number of value sections we have to match.      # Get the number of value sections we have to match.
1985      my $sectionCount = scalar(@values);      my $sectionCount = scalar(@values);
1986      # Loop through the assignments found.      # Loop through the assignments found.
# Line 1991  Line 1993 
1993                                                                  ]);                                                                  ]);
1994          # Form the key from the real key and the sub key.          # Form the key from the real key and the sub key.
1995          my $key = $self->JoinKey($realKey, $subKey);          my $key = $self->JoinKey($realKey, $subKey);
1996            # Check for a duplicate.
1997            my $wholeThing = join($self->{splitter}, $id, $key, $valueString);
1998            if (! $dupHash{$wholeThing}) {
1999                # It's okay, we're not a duplicate. Insure we don't duplicate this result.
2000                $dupHash{$wholeThing} = 1;
2001          # Break the value into sections.          # Break the value into sections.
2002          my @sections = split($self->{splitter}, $valueString);          my @sections = split($self->{splitter}, $valueString);
2003          # Match each section against the incoming values. We'll assume we're          # Match each section against the incoming values. We'll assume we're
# Line 2016  Line 2023 
2023              push @retVal, [$id, $key, @sections];              push @retVal, [$id, $key, @sections];
2024          }          }
2025      }      }
2026        }
2027      # Return the rows found.      # Return the rows found.
2028      return @retVal;      return @retVal;
2029  }  }
# Line 2201  Line 2209 
2209      # Copy the pattern into the return area.      # Copy the pattern into the return area.
2210      $escapedValue = $sqlPattern;      $escapedValue = $sqlPattern;
2211      # Check the pattern. Is it generic or exact?      # Check the pattern. Is it generic or exact?
2212      if ($sqlPattern =~ /%$/) {      if ($sqlPattern =~ /(.+)%$/) {
2213          # Yes, it is. We need a LIKE clause and we must escape the underscores          # Yes, it is. We need a LIKE clause and we must escape the underscores
2214          # and percents in the pattern.          # and percents in the pattern (except for the last one, of course).
2215            $escapedValue = $1;
2216          $escapedValue =~ s/(%|_)/\\$1/g;          $escapedValue =~ s/(%|_)/\\$1/g;
2217            $escapedValue .= "%";
2218          $sqlClause = "$tableName($fieldName) LIKE ?";          $sqlClause = "$tableName($fieldName) LIKE ?";
2219      } else {      } else {
2220          # No, it isn't. We use an equality clause.          # No, it isn't. We use an equality clause.

Legend:
Removed from v.1.33  
changed lines
  Added in v.1.36

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3