CakePHP + Sphinx: Applying filters to your search

Using the SphinxBehavior, you can filter out the search query based on the record owner. Imagine you have a ‘Clients’ table that belongs to an ‘Account’. In cakePHP, this requires you to have a field ‘account_id’ in the ‘clients’ table. In order to perform a query to Sphinx to return the records only owned by the current user, you need to do this:
$this->userinfo = $this->Auth->user(); //assuming you are using Auth component
$sphinx = array( 'index' => array('clients'), 'filter' => array( array( 'account_id', $this->userinfo['Account']['id'])), 'matchMode' => 'SPH_MATCH_ALL', 'sortMode' => array( 'SPH_SORT_EXTENDED' => '@weight DESC, @id DESC' ));