From c803dd63509888d2d3ddc1b3bb1595952336c3d4 Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Mon, 8 Jun 2009 00:17:37 +0000 Subject: [PATCH] API CHANGE #3548 ajshort: Allow a column argument for Query::column() git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@78557 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/model/Database.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/core/model/Database.php b/core/model/Database.php index a8bc4f8be..1239ec1f5 100755 --- a/core/model/Database.php +++ b/core/model/Database.php @@ -702,15 +702,20 @@ abstract class Query extends Object implements Iterator { private $queryHasBegun = false; /** - * Return an array containing all values in the leftmost column. + * Return an array containing all the values from a specific column. If no column is set, then the first will be + * returned + * + * @param string $column * @return array */ - public function column() { - $column = array(); + public function column($column = null) { + $result = array(); + foreach($this as $record) { - $column[] = reset($record); + $result[] = ($column) ? $record[$column] : reset($record); } - return $column; + + return $result; } /**