From 3a7ae3f20ee7d1aefa48560e269bf79c27578610 Mon Sep 17 00:00:00 2001 From: lissav Date: Wed, 14 Jan 2009 19:57:39 +0000 Subject: [PATCH] fix usage of getAllEntries, adding a flag for all and default only entries that are not disabled git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@2605 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/Table.pm | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/perl-xCAT/xCAT/Table.pm b/perl-xCAT/xCAT/Table.pm index 75f98af36..b7848eb8d 100644 --- a/perl-xCAT/xCAT/Table.pm +++ b/perl-xCAT/xCAT/Table.pm @@ -1256,6 +1256,9 @@ sub getNodeAttribs_nosub_returnany Arguments: Table handle + "all" return all lines ( even disabled) + Default is to return only lines that have not been disabled + Returns: Hash containing all rows in table Globals: @@ -1265,7 +1268,8 @@ sub getNodeAttribs_nosub_returnany Example: my $tabh = xCAT::Table->new($table); - my $recs=$tabh->getAllEntries(); + my $recs=$tabh->getAllEntries(); # returns entries not disabled + my $recs=$tabh->getAllEntries("all"); # returns all entries Comments: none @@ -1276,8 +1280,18 @@ sub getNodeAttribs_nosub_returnany sub getAllEntries { my $self = shift; + my $allentries = shift; my @rets; - my $query = $self->{dbh}->prepare('SELECT * FROM ' . $self->{tabname}); + my $query; + + if ($allentries) { # get all lines + $query = $self->{dbh}->prepare('SELECT * FROM ' . $self->{tabname}); + } else { # get only enabled lines + $query = $self->{dbh}->prepare('SELECT * FROM ' + . $self->{tabname} + . " WHERE \"disable\" is NULL or \"disable\" in ('','0','no','NO','no')"); + } + $query->execute(); while (my $data = $query->fetchrow_hashref()) {