I'm trying to get the sum of votes for a given user.

Say this is posts table

```
id | body  | user_id | vote_total | type
1    test     1          4          new
2    test2    1          3          new
3    test3    2          2          new

```

I'm trying to get the following output

```
user_id  | vote_total
 1          7
 2          2

```

Here's my function in PostsController

```
 public function topvotes(){ 
    $virtualFields = array('total' => 'SUM(Post.vote_total)');
    $total = $this->Post->find('all', array(
                            array('fields' => array('total'), 
                            'recursive' => 1,
                            'group' => array('Post.user_id'),
                            'conditions'=>array('Post.type' => 'new' ))));

    $post = $this->Post->find('all', $total);
    $this->set('posts', $post);
}

```

This query works (I tried with phpmyadmin) but I can't figure out how to access the resulting array

**edit I got it to work using the following query**

```
$query = $this->Post->query("select posts.user_id, SUM(Posts.vote_total) from posts where posts.type = 'new' group by posts.user_id");
    $this->set('posts', $query);

```

when I type print\_r this is the array

```
Array ( [posts] => Array ( [user_id] => 7 ) [0] => Array ( [total] => 6 ) ) 1

```