diff options
author | mkanat%bugzilla.org <> | 2009-08-11 06:34:17 +0200 |
---|---|---|
committer | mkanat%bugzilla.org <> | 2009-08-11 06:34:17 +0200 |
commit | ea25630305fbd3b55c142c32aab82f9cc7afccfa (patch) | |
tree | 1b554df79fe0a83a02075566615552783e9e873b /Bugzilla/Object.pm | |
parent | 918a8c245f8d0d7d0926a015aa9a4940c14ebdd3 (diff) | |
download | bugzilla-ea25630305fbd3b55c142c32aab82f9cc7afccfa.tar.gz bugzilla-ea25630305fbd3b55c142c32aab82f9cc7afccfa.tar.xz |
Bug 509045: Make "use_keywords" a global template variable instead of having to pass it to templates all the time
Patch by Max Kanat-Alexander <mkanat@bugzilla.org> r=LpSolit, a=LpSolit
Diffstat (limited to 'Bugzilla/Object.pm')
-rw-r--r-- | Bugzilla/Object.pm | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/Bugzilla/Object.pm b/Bugzilla/Object.pm index d2e5a8dda..cfa2bfeb6 100644 --- a/Bugzilla/Object.pm +++ b/Bugzilla/Object.pm @@ -170,14 +170,16 @@ sub match { elsif ( $field eq 'WHERE' ) { # the WHERE value is a hashref where the keys are # "column_name operator ?" and values are the placeholder's - # value. - foreach my $k (keys( %$value )) { - push( @terms, $k ); - push( @values, $value->{$k} ); + # value (either a scalar or an array of values). + foreach my $k (keys %$value) { + push(@terms, $k); + my @this_value = ref($value->{$k}) ? @{ $value->{$k} } + : ($value->{$k}); + push(@values, @this_value); } next; } - + if (ref $value eq 'ARRAY') { # IN () is invalid SQL, and if we have an empty list # to match against, we're just returning an empty @@ -335,6 +337,15 @@ sub remove_from_db { #### Subroutines ###### ############################### +sub any_exist { + my $class = shift; + my $table = $class->DB_TABLE; + my $dbh = Bugzilla->dbh; + my $any_exist = $dbh->selectrow_array( + "SELECT 1 FROM $table " . $dbh->sql_limit(1)); + return $any_exist ? 1 : 0; +} + sub create { my ($class, $params) = @_; my $dbh = Bugzilla->dbh; @@ -880,6 +891,11 @@ Returns C<1> if the passed-in value is true, C<0> otherwise. =over +=item C<any_exist> + +Returns C<1> if there are any of these objects in the database, +C<0> otherwise. + =item C<get_all> Description: Returns all objects in this table from the database. |