From ea25630305fbd3b55c142c32aab82f9cc7afccfa Mon Sep 17 00:00:00 2001 From: "mkanat%bugzilla.org" <> Date: Tue, 11 Aug 2009 04:34:17 +0000 Subject: 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 r=LpSolit, a=LpSolit --- Bugzilla/Object.pm | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'Bugzilla/Object.pm') 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 + +Returns C<1> if there are any of these objects in the database, +C<0> otherwise. + =item C Description: Returns all objects in this table from the database. -- cgit v1.2.3-24-g4f1b