Sunday, November 16, 2014

Re: hasMany and find()

Thank you John.

counterCache seems to be a good idea. 
But there must be a way to do this without adding a column to an existing table.



2014年11月15日土曜日 4時35分05秒 UTC+9 John Andersen:
Assuming you are using CakePHP 2.x, then please take a look at the counterCache feature.
http://book.cakephp.org/2.0/en/models/associations-linking-models-together.html#countercache-cache-your-count

Implement it and then you can use a condition where the counterCache count = 0.

Enjoy, John

On Friday, 7 November 2014 06:05:07 UTC+2, Kento Furui wrote:
I have a model setup like following;

Parent hasMany Children

What do I do when I want to find a Parent who doesn't have any Children?

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: