Hi just need to know whether you can query the database from inside a helper class, whether you should and how you do it.
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You could, by passing a reference to the Model into the View as a variable via $this->set() and then querying it…but you shouldn’t. It’s messy 😉
CakePHP uses the MVC model, and helpers are part of the View (the V of MVC) – their job is purely to display the (already available) information passed to it from the controller.
If your view needs extra information , then your controller should have already queried the Models to get it.
I’d suggest you read up on the MVC model if you’re not familiar with it, then some refactoring might be in order!