@larry: that was a good one :) i dont think "adallas" will get very far with his special disk-space- saving-techniques...
On 2 Jun., 01:09, "Larry E. Masters aka PhpNut" <[email protected]> wrote: > I know this is documented and it is part of the CakePHP conventions. > Maybe it is time to upgrade your 1.44 floppy to something like a zip drive? > > -- > /** > * @author Larry E. Masters > * @var string $userName > * @param string $realName > * @returns string aka PhpNut > * @access public > */ > > On Mon, Jun 1, 2009 at 5:49 PM, adallas <[email protected]> wrote: > > > 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---
