I have a users table that has location attributes and would like to create a model function that retrieves nearby users (within a given radius). Here is my model:

```

    class User extends AppModel {
        public function getNearbyUsers($id,$dist=10) {
            return $this->query(...);
        }
    }

```

And here is my controller where I am trying to invoke the function:

```

    class UsersController extends AppController {
        public function getNearbyUsers($id) {
            ...
            $this->User->getNearbyUsers($id)
            ...
        }
    }

```

However doing so results in: `PHP Fatal error: Call to a member function getNearbyUsers() on a non-object`

What am I doing wrong?

EDIT: nevermind, it is not complaining about that anymore. But it is throwing an SQL error and my model function is never actually being called. Upon further inspection on the mysql query log I see this:

```

    Query   SHOW TABLES FROM `xxx`
    Query   getNearbyUsers
    Quit

```

Seems CakePHP is interpreting $this->User->getNearbyUsers as a literal query. So my question still remains: how to add custom functions to a model in Cake?