easyrider
easyrider

Reputation: 701

How to pass var from model to view?

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?

Upvotes: 0

Views: 689

Answers (1)

Tyler
Tyler

Reputation: 2126

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.

Upvotes: 6

Related Questions