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
This commit is contained in:
Sam Minnee 2009-06-08 00:17:37 +00:00
parent 44639ca404
commit c803dd6350

View File

@ -702,15 +702,20 @@ abstract class Query extends Object implements Iterator {
private $queryHasBegun = false; 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 * @return array
*/ */
public function column() { public function column($column = null) {
$column = array(); $result = array();
foreach($this as $record) { foreach($this as $record) {
$column[] = reset($record); $result[] = ($column) ? $record[$column] : reset($record);
} }
return $column;
return $result;
} }
/** /**