function SelectQueryInterface::orderRandom

Orders the result set by a random value.

This may be stacked with other orderBy() calls. If so, the query will order by each specified field, including this one, in the order called. Although this method may be called multiple times on the same query, doing so is not particularly useful.

Note: The method used by most drivers may not scale to very large result sets. If you need to work with extremely large data sets, you may create your own database driver by subclassing off of an existing driver and implementing your own randomization mechanism. See

http://jan.kneschke.de/projects/mysql/order-by-rand/

for an example of such an alternate sorting mechanism.

Return value

SelectQueryInterface The called object

2 methods override SelectQueryInterface::orderRandom()
SelectQuery::orderRandom in includes/database/select.inc
Orders the result set by a random value.
SelectQueryExtender::orderRandom in includes/database/select.inc
Orders the result set by a random value.

File

includes/database/select.inc, line 407

Class

SelectQueryInterface
Interface definition for a Select Query object.

Code

public function orderRandom();

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.