Why does CakePHP use this method name in a MySQL query rather than return the result?

后端 未结 2 587
孤街浪徒
孤街浪徒 2021-01-24 23:51

In applying the answer from a previous question, I tried overriding one of CakePHP\'s built-in pagination methods:

function paginateCount($conditions = null, $re         


        
相关标签:
2条回答
  • 2021-01-25 00:31

    This usually happens when CakePHP can't find the method in the model or attached behaviors.

    It then passes the call to the datasource (hoping it has the method and knows what to do) and that's why you get this error.

    I would check things are what they seem (is the method in the right model, is Cake making an automodel because of incorrect filenaming, etc.)

    0 讨论(0)
  • 2021-01-25 00:33

    I've fixed this without really addressing the question I asked.

    Instead of passing the adjusted parameters up the chain as I wanted to do in my above example, I've used them to do the same job directly:

    return $this->find('count', compact($conditions, $recursive, $extra));
    

    This works OK, but doesn't explain the odd behaviour that caused me to ask the question in the first place. My guess is that Cake is doing something funky with virtual/"automagic" methods.

    0 讨论(0)
提交回复
热议问题