0
votes

I have got

return $query;

function in my model. How can I pass it to the view?

My method is:

public function findByTypes($data = array()) { $this->Type->Behaviors->attach('Containable', array('autoFields' => false)); $this->Type->Behaviors->attach('Search.Searchable');

    $query = $this->Type->getQuery('all', array(
                'conditions' => array('Type.id' =>
                    $data['title']),
                'fields' => array('id'),
                'contain' => array('Ticket')
            ));
    return $query;
}

how can I get query result?

1
You need to add quite a bit more explanation and code to get a fully functional answer, but...If you only have data in the model it technically (without hacking the MVC model) needs to go to the controller first, then passed to the view with a $this->set('name',$var); - user719367

1 Answers

6
votes

In your controller:

function view() {
    ...
    $data = $this->Model->findByTypes(...);
    $this->set('data', $data);
}

It will be made available as the variable $data in your view.