laravel/laravel — Issue #208: Query aggregate with select
Author: akhodakivskiy
Created: 2011-12-12 15:09:02+00:00
State: open

DB::table('users')->select('name')->count()

will result in a query

SELECT COUNT(*) SELECT `name` FROM `sm_users`

Possible solutions:

1. Within `Query::aggregate`: backup selects, set them to null, and then restore

```PHP
private function aggregate($aggregator, $column)
{
$selects_backup = $this->selects;
$this->selects = null;

$result = ... //function body

$this->seelcts = $selects_backup;

return $result;
}
```

2. Ignore selects if aggregate is set in the Grammar::select

```PHP
foreach ($this->components as $component)
{
if (($component === 'selects') && (!is_null($query->aggregate))) {
continue;
}
// proceed with component
}
```