问题
I have two variables in my controller in CakePHP which are accessed using
$this->data['General']['q']
$this->data['General']['typesearch'].
How Do I refer to these variables in the model???
回答1:
You didn't specify why do you need those variables in your model. Because the context is very important for this kind of questions, it's hard to accurately answer the one without it.
Well, you could try defining variables in your model first:
Class MyModel Extends AppModel {
var $q;
var $typesearch;
}
Then, in your controller you could try to pass the values of controller variables to those variables:
$this->MyModel->q = $this->data['General']['q'];
$this->MyModel->typesearch = $this->data['General']['typesearch'];
Regards, Hiawatha
来源:https://stackoverflow.com/questions/10987489/accessing-controller-variables-in-model-cakephp