On Jul 14, 5:29 pm, Spark <[EMAIL PROTECTED]> wrote:
>    As documented in MySQL manual, getting something random on a SQL
> call is dozens, hundreds of times slower than a common 'ORDER BY'.
> They even suggest using the language you are using (php, j2ee, .net)
> to achieve your goal.http://dev.mysql.com/doc/refman/5.0/en/select.html#c2161
>
>    I'd like to know other solutions, inside cakephp, to this problem..
> Which one is *the* solution.. should I care? cache that thing and live
> with it? :)

I use this behavior: 
http://trac.assembla.com/cake-base/browser/branches/sample_app/app/models/behaviors/random.php

Which in principle converts
     ORDER BY RAND()
into
     WHERE Model.afieldnamedrandom > random value ORDER BY (a field
with a random value)

and randomizes the values in afieldnamedrandom once a day.

There's a test case which demonstrates the more 'advanced' use of it:
http://trac.assembla.com/cake-base/browser/branches/sample_app/app/tests/cases/behaviors/random.test.php

hth,

AD

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to