Cake has some nice support for modeling many to many relations using ‘hasManyAndBelongsTo’. There’s a simple example here.
Though this works well for simple connections between classes, you can’t do much else. Taking the classic Blog-style Posts and Tags example, this approach will easily let you link multiple tags to multiple posts. But what if you want to track the date that a tag was applied to a post? If you add a date field to the join table, it seems pretty much impossible to retrieve it, and setting it is even harder. You can search on it by twiddling with the conditions on the relation, but that’s ugly. I think in that case, you have no option but to model the relation explicitly with two pairs of hasMany/belongsTo relations linked through a PostTag model, and then you’ll have to set your recursion deeper and get busy with unbindmodel in order to keep the number of queries down. Who knows, I might even write up an example and post it here…
Php.ini not loading?
I beat my head against this one for hours. A recompiled version of PHP 5.1.6 on OS X was simply not loading my php.ini, even though a valid file existed in the place specified by the –with-config-file-path configure setting (/etc), and no other php.ini files existed on the system.
Eventually, after many rebuilds, I downloaded a clean copy of the source, rebuilt from scratch and voila – it worked. however, changing it and recompiling prodiced the broken results again. make distclean and a rebuild made it ork again. So, if you’re seeing this problem, a clean recompile (don’t forget to use config.nice) should make it all work again.
I’m not sure if this is a PHP bug or not – is it meant to work?