开发者

How do I track my parent find function call in beforeFind() for CakePHP

开发者 https://www.devze.com 2023-04-02 17:01 出处:网络
I am currently using CakePHP beforeFind() to filter my search queries based on the current logged in user.It seems great at the moment and everything is working smoothly, the only problem is that I ne

I am currently using CakePHP beforeFind() to filter my search queries based on the current logged in user. It seems great at the moment and everything is working smoothly, the only problem is that I need to know where the find function was initially called so that I can apply different query filters based on the parent find function call; is there anyway开发者_StackOverflow中文版 to achieve that?


That seems like coupling your models to your controllers/actions, which in general is a bad idea.

Try creating a custom method in your model instead. You can have whatever method signature you need, and just call find from within and return its results as needed.

0

精彩评论

暂无评论...
验证码 换一张
取 消