I'm new to Cakephp2 and I wanted to ask a question to the pros. How to call a function in model in a controller in cakephp2? I've read the documentation but it's not clear to me since I'm a newbie.It would be great if I can attain clear explanation! Thank you!
For example I have a model named Android and in that model there is a function
public function _checkUaType($ua) {
}
Should I call the function like $this->Android->_checkUaType($ua)
? Or are there a better way to use a function in a controller?
You need to just load the model in the controller and call Model function as below example.
In the Controller use below code:
function YourFunctionName {
$this->loadModel('Android');
$this->Android->_checkUaType($ua);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.