I just tracked a bug through Cake's Model code (specifically, model/ datasources/dbo_source.php). I was shocked at how small the scope of the problem turned out to be.
My find('all'...) included a condition, Model.fld = 3. The results were wrong and after some wasted time, I saw that the generated SQL included Model.fld = 1. Cake wasn't just adding some identity condition; or if it was, it was throwing my condition away. It's a complicated model (Model, in this case, has 9 associations). I assumed it had something to do with that, but it did not. Cake thinks that Tinyints are booleans. Cake parses and reconstructs your conditional phrases. Put those two facts together, and you see that Model.fld = 0 will work. Model.fld = 1 will work. Model.fld = 2 will morph into Model.fld = 3. One solution is to use ints instead of tinyints. Ints take 4 bytes per record, tinyints take 1. I can't bring myself to waste the space without a good reason. I suppose that's the Cake way--if you'll be treating the field like an ordinary int, use an ordinary int type. The solution I used was the result of carefully plodding through the dbo_source code--I override Model::getColumnType(). You can force any type for a given key. The code is: public function getColumnType($key) { if ($key == 'MyModel.fld') { return 'integer'; // not 'int' } return parent::getColumnType($key); } I hope it helps someone avoid some debugging. /alastair/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---