Hi,

On 2009/11/28, at 17:19, Alberto Simões wrote:

 SELECT word FROM words ORDER BY RANDOM() LIMIT 10;

to get 10 random words from a database.
I am trying to do the same query using DBIx::Class, but not sure what
to set as order_by clause:

           my @words = $schema->resultset('Word')->search(undef,
{rows => $LIMIT, order_by => ...????
                                                           columns =>
['word']});

Untested but try order_by => \'RANDOM()'

In other places, when you need to put direct SQL, you use a scalar ref. Might work for order_by.

Bye,
_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[email protected]

Reply via email to