2014-11-26 03:57
浏览 49

Cakephp2:如何在Controller in Model中调用和使用该函数

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?

图片转代码服务由CSDN问答提供 功能建议

我是Cakephp2的新手,我想向专业人士提问。 如何调用函数 在cakephp2中的控制器模型? 我已经阅读了文档,但是我不清楚,因为我是新手。如果我能得到明确的解释,那将是很棒的! 谢谢!


  public function _checkUaType($ ua  ){

我应该像 $ this-> Android-> _checkUaType($ ua)? 或者有更好的方法在控制器中使用功能?

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • donglvchu9143 2014-11-29 10:46

    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 {
    打赏 评论

相关推荐 更多相似问题