Skip to content

Commit

Permalink
Fix another bug in fetchColumn()
Browse files Browse the repository at this point in the history
  • Loading branch information
Olivier Poitrey committed Nov 13, 2008
1 parent fdf15ce commit 2fffd20
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions MyDBD/ResultSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,24 +286,31 @@ public function fetchColumn($col = null)

if (is_int($col))
{
$arr = $this->fetchArray();
$data = $this->fetchArray();

}
elseif (is_string($col))
{
$arr = $this->fetchAssoc();
$data = $this->fetchAssoc();
}
else
{
throw new InvalidArgumentException('Invalid column reference: . ' . $col);
}

if (!array_key_exists($col, $arr))
if (isset($data))
{
throw new OutOfBoundsException('Invalid column name or index: ' . $col);
}
if (!array_key_exists($col, $data))
{
throw new OutOfBoundsException('Invalid column name or index: ' . $col);
}

return $arr[$col];
return $data[$col];
}
else
{
return null;
}
}

// PEAR::Db compatibility layer
Expand Down

0 comments on commit 2fffd20

Please sign in to comment.