expand getAllAttribsWhere to accetp ALL to return all attributes in the table

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@5731 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
lissav 2010-04-09 13:37:51 +00:00
parent 5416f126a6
commit 7bb245ceef

View File

@ -2394,6 +2394,9 @@ sub getAllEntries
Example:
$nodelist->getAllAttribsWhere("groups like '%".$atom."%'",'node','group');
returns node and group attributes
$nodelist->getAllAttribsWhere("groups like '%".$atom."%'",'ALL');
returns all attributes
Comments:
none
@ -2435,16 +2438,27 @@ sub getAllAttribsWhere
while (my $data = $query->fetchrow_hashref())
{
my %newrow = ();
foreach (@attribs)
{
if ($attribs[0] eq "ALL") { # want all attributes
foreach (keys %$data){
if ($data->{$_} =~ /^$/)
{
$data->{$_} = undef;
}
}
push @results, $data;
} else { # want specific attributes
foreach (@attribs)
{
unless ($data->{$_} =~ /^$/ || !defined($data->{$_}))
{ #The reason we do this is to undef fields in rows that may still be returned..
$newrow{$_} = $data->{$_};
}
}
if (keys %newrow)
{
push(@results, \%newrow);
}
if (keys %newrow)
{
push(@results, \%newrow);
}
}
}
$query->finish();