I learned ruby on rails before php and need a quick answer.
I’m trying to do something like this in CakePHP.
@foo = Foo.find(:all)
@some_foos = @foo.select { |i| i.status == 4 }
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.
Roughly translates to:
In other words, it’s calling the static find method on the Foo ActiveRecord and assigns the result. Then it selects from those results those records which satisfy the anonymous function and assigns those as well.
Try this for CakePHP (untested):
If you dont need all the Foos, you want to fetch the relevant records instead:
or via raw SQL