dpleylxzx47207117 2014-11-26 03:57
浏览 54
已采纳

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?

  • 写回答

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 {
        $this->loadModel('Android');
        $this->Android->_checkUaType($ua);
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!